部署页面状态启动映像存储在根目录中。
但是,当使用FileExists时,以下所有路径都返回false,因此…
FileExists(TPath.GetHomePath + PathDelim + 'LaunchImage_320x480.png');
FileExists(TPath.GetHomePath + PathDelim + Application.Title + '.app' + PathDelim + 'LaunchImage_320x480.png');
FileExists(TPath.GetDocumentsPath + PathDelim + 'LaunchImage_320x480.png');
FileExists('' + 'LaunchImage_320x480.png');
FileExists('.' + 'LaunchImage_320x480.png');
启动图像应与文档中描述的应用程序存储在同一文件夹中。您应该能够使用NSBundle.pathForResource.获取文件名
uses
iOSapi.Foundation, Macapi.Helpers;
procedure TForm1.FormCreate(Sender: TObject);
var
FileName: string;
begin
FileName := NSStrToStr(TNSBundle.Wrap(TNSBundle.OCClass.mainBundle).pathForResource(NSSTR('Default'), NSStr('png')));
//....
end;
诀窍可能是启动映像的文件名不一定与IDE中的文件名相同。你可以这样列出应用程序中的所有文件:
uses
iOSapi.Foundation, Macapi.Helpers, System.IOUtils;
procedure TForm1.Button1Click(Sender: TObject);
var
FileName: string;
files: TStringDynArray;
AppFolder: string;
I: Integer;
begin
AppFolder := NSStrToStr((TNSBundle.Wrap(TNSBundle.OCClass.mainBundle).bundlePath));
Files := TDirectory.GetFiles(AppFolder);
for I := 0 to Length(Files) - 1 do
Memo1.Lines.Add(ExtractFileName(Files[I]));
end;
你也可以使用像DiskAid这样的工具来查看Windows上的iOS应用程序文件夹。
默认图像存储在此目录中(您可以使用MacOS上的终端找到它)
DirPath := TPath.Combine(TPath.GetHomePath, Application.Title + '.app');
如果您询问如何定位自上传文件,以下是说明:
- 从主菜单中单击
Project
>Deployment
- 单击
Add files
添加所需文件 - 将文件位置从
.
更改为StartUpDocuments
- 单击
Connect to Remote Machine
按钮(几秒钟后,列Remote Status
应显示Missing
- 点击
Deploy
按钮,等待Remote Status
变成Same
现在,该文件应该可以从您的应用程序代码访问:
ImagePath := TPath.Combine(TPath.GetDocumentsPath, 'LaunchImage_320x480.png');
if FileExists(ImagePath) then
Image1.Bitmap.LoadFromFile(ImagePath);
编译你的代码在你的iOS设备或iOS模拟器中运行。它应该工作,并有乐趣!
注意:
- 文件名在iOS上区分大小写
- 不要将
.bmp
上传到iOS,因为我认为iOS不支持位图 - Andriod设备的文件位置不同。(但谁在乎呢)