xcode iPhone - 多目标多发射图像噩梦
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10056794/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
iPhone - multiple targets multiple launch images nightmare
提问by DuckDucking
I have a project with 2 applications in two flavors each, iPhone and iPad. So, the project has 4 targets. It is obviously not universal.
我有一个项目,其中有 2 个应用程序,每个应用程序有两种风格,iPhone 和 iPad。因此,该项目有 4 个目标。显然不是万能的。
To easy things, lets call each application AAA and BBB.
为了简单起见,让我们将每个应用程序称为 AAA 和 BBB。
The launch images are named like this:
启动图像的名称如下:
AAA for iPhone
iPhone AAA
- AAAiPhone.png
- [email protected]
- AAAiPhone.png
- [email protected]
AAA for iPad
iPad AAA
- [email protected]
- AAAiPad-Portrait.png
- [email protected]
- AAAiPad-Landscape.png
- [email protected]
- AAAiPad-Portrait.png
- [email protected]
- AAAiPad-Landscape.png
The BBB images have the same name structure, with BBB instead of AAA in the name.
BBB 图像具有相同的名称结构,名称中使用 BBB 而不是 AAA。
I have added this UILaunchImageFile to each plist, like this:
我已将此 UILaunchImageFile 添加到每个 plist,如下所示:
- AAA for iPhone ... Launch Image (iPhone) = AAAiPhone.png
- AAA for iPad ... Launch Image (iPad) = AAAiPad.png
- BBB for iPhone ... Launch Image (iPhone) = BBBiPhone.png
- BBB for iPad ... Launch Image (iPad) = BBBiPad.png
- iPhone 的 AAA ... 启动图像 (iPhone) = AAAiPhone.png
- iPad 的 AAA ... 启动图像 (iPad) = AAAiPad.png
- iPhone 版 BBB ... 启动图片 (iPhone) = BBBiPhone.png
- 适用于 iPad 的 BBB ... 启动图像 (iPad) = BBBiPad.png
When I drag the images to the proper place holder on Xcode it goes fine for AAA, but when I do that for BBB it overwrites all AAA images. It appears to be ignoring the info.plist information.
当我将图像拖到 Xcode 上的适当占位符时,AAA 可以正常工作,但是当我为 BBB 执行此操作时,它会覆盖所有 AAA 图像。它似乎忽略了 info.plist 信息。
Any clues?
有什么线索吗?
thanks
谢谢
回答by Jonas Schnelli
It's because the images are renamed to Default.png (or another name same for each target).
这是因为图像被重命名为 Default.png(或每个目标的另一个名称)。
You need to do it like this:
你需要这样做:
Add a entry in your plist for each target. iPad: Launch image (iPad) iPhone Launch image (iPhone)
在您的 plist 中为每个目标添加一个条目。iPad:启动图像 (iPad) iPhone 启动图像 (iPhone)
Use a different string for each target. Place the images with that string to your resource files (also make sure that only the desired images are active in the desired target).
为每个目标使用不同的字符串。将带有该字符串的图像放入您的资源文件中(还要确保在所需的目标中只有所需的图像处于活动状态)。
Example:
示例:
Target 1
- plist: Launch image (iPad) = AAADefaultiPad
- Place files: [email protected] and AAADefaultiPad.png
Target 2
- plist: Launch image (iPad) = BBBDefaultiPhone
- Place files: [email protected] and BBBDefaultiPhone.png
目标 1
- plist:启动图像 (iPad) = AAADefaultiPad
- 放置文件:[email protected] 和 AAADefaultiPad.png
目标 2
- plist:启动图像 (iPad) = BBBDefaultiPhone
- 放置文件:[email protected] 和 BBBDefaultiPhone.png
Edit 1:Place the images as you would place a image file into your graphic resources. Do not place it in the image space under Target "Summary".
编辑 1:像将图像文件放入图形资源一样放置图像。不要将其放置在目标“摘要”下的图像空间中。
Works for me pretty well.
对我来说效果很好。
回答by Brennan
I've written up instructions along with a GitHub project.
我已经编写了说明以及 GitHub 项目。
https://github.com/brennanMKE/MultipleTargets
https://github.com/brennanMKE/MultipleTargets
There are many steps and details to handle for everything you will want to do to fully support multiple target builds from a single Xcode project. That sample addresses...
为了完全支持从单个 Xcode 项目构建多个目标,您需要处理许多步骤和细节。该示例地址...
- Unique app identifier for each build target
- Unique launch graphics
- Unique app icons
- Custom C Flags to manage distinct functionality for each build target
- 每个构建目标的唯一应用标识符
- 独特的启动图形
- 独特的应用程序图标
- 自定义 C 标志来管理每个构建目标的不同功能
回答by Max Hiroyuki Ueda
I had some problems regarding multiple targets(iPhone) X multiple launch images/multiple icons when I had to add Retina icons & launch images. To solve this, I had to do do the following in plist:
当我不得不添加 Retina 图标和启动图像时,我在多个目标(iPhone)X 多个启动图像/多个图标方面遇到了一些问题。为了解决这个问题,我必须在 plist 中执行以下操作:
- Regarding Icons(low res & retina): In each target, I deleted the entry Icon Files (iOS 5), and added another one (Icon file). Then I modified this row (Icon file) to Icon files (basically, in singular it's type is String, and plural it automatically becomes Array), and added the image files reference, as the following:
- 关于图标(低分辨率和视网膜):在每个目标中,我删除了条目图标文件(iOS 5),并添加了另一个(图标文件)。然后我将此行(图标文件)修改为图标文件(基本上,单数类型为字符串,复数类型自动变为数组),并添加图像文件引用,如下所示:
- Regarding the launch images (low res & retina): I did as Jonas suggested, but using the image with retina specs (640 x 960). It works both in low res and hi res.
- 关于发射图像(低分辨率和视网膜):我按照乔纳斯的建议做了,但使用具有视网膜规格(640 x 960)的图像。它适用于低分辨率和高分辨率。
回答by Tibidabo
It is actually very simple:
其实很简单:
Define "Launch image" in plist with a string you want to replace "Default" in the file name. Default.png becomes MyAppName.png etc.
Simply create your filenames conforming with default filenames such as:
使用要替换文件名中的“默认”的字符串在 plist 中定义“启动图像”。Default.png 变成 MyAppName.png 等。
只需创建符合默认文件名的文件名,例如:
MyAppName.png
我的应用程序名称.png
MyAppName-Landscape@2x~ipad.png
MyAppName-Landscape@2x~ipad.png
MyAppName-Landscape~ipad.png
MyAppName-Landscape~ipad.png
MyAppName-Portrait@2x~ipad.png
MyAppName-Portrait@2x~ipad.png
MyAppName-Portrait~ipad.png
MyAppName-Portrait~ipad.png