我编辑了info.plist并添加了UILaunchImages键。但是,我无法让该应用显示我想要的启动图像。我这样做是为了尝试为iPhone创建横向启动图像。这是代码。
<key>UILaunchImages</key>
<array>
<dict>
<key>UILaunchImageMinimumOSVersion</key>
<string>8.0</string>
<key>UILaunchImageName</key>
<string>Default</string>
<key>UILaunchImageOrientation</key>
<string>Portrait</string>
<key>UILaunchImageSize</key>
<string>{320, 480}</string>
</dict>
<dict>
<key>UILaunchImageMinimumOSVersion</key>
<string>8.0</string>
<key>UILaunchImageName</key>
<string>Default</string>
<key>UILaunchImageOrientation</key>
<string>Landscape</string>
<key>UILaunchImageSize</key>
<string>{320, 480}</string>
</dict>
<dict>
<key>UILaunchImageMinimumOSVersion</key>
<string>8.0</string>
<key>UILaunchImageName</key>
<string>Default-568h</string>
<key>UILaunchImageOrientation</key>
<string>Portrait</string>
<key>UILaunchImageSize</key>
<string>{320, 568}</string>
</dict>
<dict>
<key>UILaunchImageMinimumOSVersion</key>
<string>8.0</string>
<key>UILaunchImageName</key>
<string>Default-568h</string>
<key>UILaunchImageOrientation</key>
<string>Landscape</string>
<key>UILaunchImageSize</key>
<string>{320, 568}</string>
</dict>
<dict>
<key>UILaunchImageMinimumOSVersion</key>
<string>8.0</string>
<key>UILaunchImageName</key>
<string>Default-667h</string>
<key>UILaunchImageOrientation</key>
<string>Portrait</string>
<key>UILaunchImageSize</key>
<string>{375, 667}</string>
</dict>
<dict>
<key>UILaunchImageMinimumOSVersion</key>
<string>8.0</string>
<key>UILaunchImageName</key>
<string>Default-667h</string>
<key>UILaunchImageOrientation</key>
<string>Landscape</string>
<key>UILaunchImageSize</key>
<string>{375, 667}</string>
</dict>
<dict>
<key>UILaunchImageMinimumOSVersion</key>
<string>8.0</string>
<key>UILaunchImageName</key>
<string>Default-736h</string>
<key>UILaunchImageOrientation</key>
<string>Portrait</string>
<key>UILaunchImageSize</key>
<string>{414, 736}</string>
</dict>
<dict>
<key>UILaunchImageMinimumOSVersion</key>
<string>8.0</string>
<key>UILaunchImageName</key>
<string>Default-736h</string>
<key>UILaunchImageOrientation</key>
<string>Landscape</string>
<key>UILaunchImageSize</key>
<string>{414, 736}</string>
</dict>
<dict>
<key>UILaunchImageMinimumOSVersion</key>
<string>8.0</string>
<key>UILaunchImageName</key>
<string>Default-Portrait</string>
<key>UILaunchImageOrientation</key>
<string>Portrait</string>
<key>UILaunchImageSize</key>
<string>{768, 1024}</string>
</dict>
<dict>
<key>UILaunchImageMinimumOSVersion</key>
<string>8.0</string>
<key>UILaunchImageName</key>
<string>Default-Landscape</string>
<key>UILaunchImageOrientation</key>
<string>Landscape</string>
<key>UILaunchImageSize</key>
<string>{768, 1024}</string>
</dict>
</array>
我想用自己的图像替换默认值,但是当我这样做时,它只会显示黑屏。我错过了一步吗?这是iOS 8的问题吗?
最佳答案
Apple技术说明TN2244(https://developer.apple.com/library/ios/technotes/tn2244/_index.html)提供了有关如何为仅在横向模式下启动的iPhone应用程序添加UILaunchImages的一些基本信息,尤其是在要支持iOS8和iOS7的情况下。 (具体来说,它提供了上面显示的XML代码,将其粘贴到Info.plist文件后,即可在XCode的“项目设置”“信息”标签中进行编辑)。关联的图像应拖到Xcode的Project Explorer中。
该技术说明还指出,为了同时支持iOS8和早期版本,不得使用资产目录。
因此,这是一个很好的起点,但对我而言,还需要进一步充实。
对于我希望能够仅在横向模式下从iPhone4s / iOS7到iPhone6Plus / iOS8.x运行的应用程序,我遇到了很多问题。最大的问题是,尽管我已经创建了各种启动图像(在横向模式下,然后将它们旋转为纵向),将它们添加到我的项目中,并将名称准确地放入了技术说明中的UILaunchImages字典中,但启动图像会显示正确地适用于iPhone4s / iOS7,但是在iPhone5 *和iPhone6上,尽管LaunchImages中包含什么内容,仍会拾取iPhone4图像,在显示之前它将进一步旋转。
更糟糕的是,iPhone5和iPhone6然后只能在信箱模式下运行,并且报告屏幕尺寸为320x480点。在iOS8下的任何设备上运行,我将从LaunchScreen.xib文件中获取默认屏幕。我也不想这样做,因为目前无法使用自动布局。
我找到的解决方案是Alex Argo发布的,请参阅问题(How do I create launch images for iPhone 6 / 6 Plus Landscape Only Apps?)。这涉及向Info.plist添加更多键,即使不使用肖像图像也要添加肖像图像。请在下面注意“肖像”的其他条目,这些条目未包含在“技术说明”中。
<key>UILaunchImages</key>
<array>
<dict>
<key>UILaunchImageMinimumOSVersion</key>
<string>7.0</string>
<key>UILaunchImageName</key>
<string>Img320x568ptsPort@2x</string>
<key>UILaunchImageOrientation</key>
<string>Landscape</string>
<key>UILaunchImageSize</key>
<string>{320, 568}</string>
</dict>
<dict>
<key>UILaunchImageMinimumOSVersion</key>
<string>7.0</string>
<key>UILaunchImageName</key>
<string>Img320x568ptsLdsc@2x</string>
<key>UILaunchImageOrientation</key>
<string>Portrait</string>
<key>UILaunchImageSize</key>
<string>{320, 568}</string>
</dict>
<dict>
<key>UILaunchImageMinimumOSVersion</key>
<string>7.0</string>
<key>UILaunchImageName</key>
<string>Img320x480ptsPort@2x</string>
<key>UILaunchImageOrientation</key>
<string>Landscape</string>
<key>UILaunchImageSize</key>
<string>{320, 480}</string>
</dict>
<dict>
<key>UILaunchImageMinimumOSVersion</key>
<string>7.0</string>
<key>UILaunchImageName</key>
<string>Img320x480ptsLdsc@2x</string>
<key>UILaunchImageOrientation</key>
<string>Portrait</string>
<key>UILaunchImageSize</key>
<string>{320, 480}</string>
</dict>
<dict>
<key>UILaunchImageMinimumOSVersion</key>
<string>8.0</string>
<key>UILaunchImageName</key>
<string>Img375x667ptsPort@2x</string>
<key>UILaunchImageOrientation</key>
<string>Landscape</string>
<key>UILaunchImageSize</key>
<string>{375, 667}</string>
</dict>
<dict>
<key>UILaunchImageMinimumOSVersion</key>
<string>8.0</string>
<key>UILaunchImageName</key>
<string>Img375x667ptsLdsc@2x</string>
<key>UILaunchImageOrientation</key>
<string>Portrait</string>
<key>UILaunchImageSize</key>
<string>{375, 667}</string>
</dict>
<dict>
<key>UILaunchImageMinimumOSVersion</key>
<string>8.0</string>
<key>UILaunchImageName</key>
<string>Img414x736ptsLdsc@3x</string>
<key>UILaunchImageOrientation</key>
<string>Landscape</string>
<key>UILaunchImageSize</key>
<string>{414, 736}</string>
</dict>
<dict>
<key>UILaunchImageMinimumOSVersion</key>
<string>8.0</string>
<key>UILaunchImageName</key>
<string>Img414x736ptsPort@3x</string>
<key>UILaunchImageOrientation</key>
<string>Portrait</string>
<key>UILaunchImageSize</key>
<string>{414, 736}</string>
</dict>
</array>
有趣的是,对于iPhone 6Plus,我发现不需要像其他所有横向发射图像一样将横向发射图像旋转为人像。
它还涉及在项目设置中清空“劳克屏幕文件”。否则,有时会在启动屏幕的情况下拾取默认的LaunchScreen.xib(这对我来说不好,因为此时我的应用程序中图形和文本之间的相互作用有点妨碍了自动布局)。
所有这些对我而言在Xcode 6.4下都有效。