如何为iPhone 6/6 Plus Landscape Only Apps创build启动图像?

我有一个现有的景观只有应用程序,我想添加iPhone 6 / iPhone 6 Plus的支持。 当我支持iOS 6/7时,我只是使用默认命名的启动肖像图像,将横向图像旋转为纵向(即对于4“屏幕,我创build了横向1136×640,然后旋转以创build640×1136启动图像)。

我试图让iOS 8和iPhone 6/6 +的东西工作,还没有拿出一些工作呢。 以下是我尝试过的一些事情:

  1. 按照4“屏幕启动图像约定的模式,我创build了Default-667h@2x.png和Default-736h@3x.png图像,这确实欺骗了模拟器以适当的iPhone 6/6 +分辨率运行,但是启动时使用4“屏幕启动图像,而不是我创build的新图像。
  2. 使用资产目录 – 我在LaunchImages资产中为iPhone 6和iPhone 6 Plus创build肖像启动图像,为iPhone 6 Plus创build一个风景图像启动图像。 iPhone 6 Plus的作品,但iPhone 6只是显示黑屏。 (在资产目录中无法创buildiPhone 6横向启动图像)
  3. 在Info.plist中指定所有屏幕大小的UILaunchImages数组(请参阅参考资料https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/ uid / TP40009252-SW28 )。 我在这里得到与资产目录类似的结果。 我可以得到iPhone 6 Plus景观工作,但不是iPhone 6的风景。

我发现一个解决scheme,使景观只启动图像在iOS 8通用。 我最终在Info.plist中使用了UILaunchImages数组。 诀窍是让图片显示,不明确支持风景(iPhone 4 / 4S,iPhone 5 / 5S / 5C,iPhone 6),你需要指定重复的条目。 看我下面的例子。 这是一个只支持横向手机应用程序,支持iPad的两个方向。 iOS 7将回退到默认的图像名称。

所有的iPhone启动图像需要像往常一样旋转到纵向,除了iPhone 6 Plus的启动图像。 它本身支持横向定位启动图像,所以您需要将其启动图像保持横向。

这里是Info.plist的相关位:

<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> 

iPhone 6等的模式已经改变了

iPhone 6( 750×1334 ):

Default-375w-667h@2x~iphone.png

iPhone 6 Plus:( 1242×2208

Default-414w-736h@3x~iphone.png

Default-Landscape@3x.png(风景)

注意,如果你支持iPad,那么你必须重命名你的iPad的默认图像,以追加〜ipad,例如Default-Portrait〜ipad.png,以防止6 plusselect这些图像,因为这些图像覆盖了3x图像。

以下步骤适用于我:

  1. 使用以下提名将图像添加到项目(根目录或资源文件夹)(我将它们描述为肖像发射图像):Default.png(3.5英寸),Default-568h@2x.png(4英寸),Default- 667h@2x.png(iPhone 6),Default-736@3x.png(iPhone 6plus)。
  2. 转至常规选项卡上的目标设置,应用程序图标和启动图像 – >将启动图像源设置为不使用资产目录(“不要使用资产目录”)。
  3. 从主图像资产中删除LaunchImage资产
  4. 转至常规选项卡上的目标设置,应用程序图标和启动图像 – >将启动图像源设置为使用资产目录
  5. XCode 6将会向您询问现有图像的图像资产迁移。 只需点击“迁移”。

它适用于iOS7,iOS8上的各种设备。 注意:如果您检查新的LaunchImage资产,那么您可以看到它真的很奇怪。 它似乎只包含几个图像,而没有iPhone6或iPhone 6plus分辨率的图像。

对于iPhone 6:

750 x 1334(@ 2x)肖像
1334 x 750(@ 2x)景观

对于iPhone 6 Plus:

1242 x 2208(@ 3x)肖像
2208 x 1242(@ 3x)景观

或者你可以通过这个链接,它可以帮助你

http://matthewpalmer.net/blog/2014/09/10/iphone-6-plus-launch-image-adaptive-mode/

如果您仅使用Images.xassets,则“启动屏幕文件”应该为空。 它帮助了我。

“启动屏幕文件”是空的

这是@ AlexArgo的答案的延续,它扩展了iOS 9的支持应用程序,使iOS 9的iPhone在iPhone 9上显示适当的启动图像。 就这个答案而言,不需要资产目录,故事板或xib。

没有这些补充,我们看到的行为是,在iOS 9 iPhone上启动我们的仅支持横向的应用程序显示与iOS 8相同的图像,但图像顺时针旋转了90度,并被拉伸到相反方向的尺寸。

预先修复iOS 9 iPhone启动屏幕: 预先修复iOS 9 iPhone启动屏幕

这个解决scheme有两个部分:

  1. 将下面的iOS 9项目添加到您的Info.plistUILaunchImages数组之前 ,@ AlexArgo的答案中的iOS 8项目。
  2. 将以下iOS 9项目(例如, Default-iOS9-568h )中引用的新启动图像添加到您的应用程序。 新推出的图像是实际的 “风景” – 取向图像(比它们高),这与@ AlexArgo的iOS 8项目引用的图像不同,后者开始为横向图像,然后在添加到应用程序之前旋转到纵向。 请注意,这两套图像必须保留在应用程序中,才能同时在iOS 8和9上使用此解决scheme。

     <key>UILaunchImages</key> <array> <dict> <key>UILaunchImageMinimumOSVersion</key> <string>9.0</string> <key>UILaunchImageName</key> <string>Default-iOS9</string> <key>UILaunchImageOrientation</key> <string>Landscape</string> <key>UILaunchImageSize</key> <string>{320, 480}</string> </dict> <dict> <key>UILaunchImageMinimumOSVersion</key> <string>9.0</string> <key>UILaunchImageName</key> <string>Default-iOS9-568h</string> <key>UILaunchImageOrientation</key> <string>Landscape</string> <key>UILaunchImageSize</key> <string>{320, 568}</string> </dict> <dict> <key>UILaunchImageMinimumOSVersion</key> <string>9.0</string> <key>UILaunchImageName</key> <string>Default-iOS9-667h</string> <key>UILaunchImageOrientation</key> <string>Landscape</string> <key>UILaunchImageSize</key> <string>{375, 667}</string> </dict> ...(pre-iOS 9 items)... </array> 

后期修复iOS 9 iPhone启动屏幕: 在这里输入图像说明

要使用ipad(横向和纵向模式),您需要在您的info.plist中添加UILaunchImages〜ipad密钥:

 <key>UILaunchImages~ipad</key> <array> <dict> <key>UILaunchImageMinimumOSVersion</key> <string>7.0</string> <key>UILaunchImageName</key> <string>Default-Landscape</string> <key>UILaunchImageOrientation</key> <string>Landscape</string> <key>UILaunchImageSize</key> <string>{768, 1024}</string> </dict> <dict> <key>UILaunchImageMinimumOSVersion</key> <string>7.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>7.0</string> <key>UILaunchImageName</key> <string>Default-Landscape</string> <key>UILaunchImageOrientation</key> <string>Landscape</string> <key>UILaunchImageSize</key> <string>{748, 1024}</string> </dict> <dict> <key>UILaunchImageMinimumOSVersion</key> <string>7.0</string> <key>UILaunchImageName</key> <string>Default-Portrait</string> <key>UILaunchImageOrientation</key> <string>Portrait</string> <key>UILaunchImageSize</key> <string>{768, 1004}</string> </dict> </array> 

对于除加号以外的所有iPhone,没有单独的仅适用于横向应用程序的启动屏幕。 您可以像Deepak所描述的那样在plist中设置方向,然后将您的肖像启动屏幕设置为风景启动屏幕的旋转版本。

这就是它一直以来的事情,唯一改变的是现在正在支持一个单独的,独特的风景启动屏幕。 所有其他设备仍然只支持肖像启动屏幕,无论您的应用程序的开始方向。

我所做的是将我的项目更改为不使用资产目录来启动图像,并使用iOS7及更早版本的旧技术。 这将获得适用于iOS7和更早版本的启动图像。

为了让他们也为iOS8工作,以便您可以得到正确的解决scheme,并确认您的应用程序为新的iPhone 6 / +构build,您还需要创build一个新的LaunchImage XIB并告诉Xcode使用它。

看来发生的事情是在iOS8设备上启动应用程序使用新的XIB技术,并在iOS7或更早版本的设备上启动应用程序使用你已经知道和喜欢的图像。

这对我来说似乎工作。 这是丑陋的海事组织,但它的作品。

希望这有助于一些人。

你只需添加iPhone6-Portrait@2x.png,那么它也将自己修复为景观。 我还为iPhone 6和iPhone 6 Plus提供了一个风景独特的应用程序,它的工作原理没有问题!

要在横向模式下启动应用程序,编辑Info.plist文件以添加具有适当值(UIInterfaceOrientationLandscapeRight或UIInterfaceOrientationLandscapeLeft)的UIInterfaceOrientation键,如下面的代码所示。 这为系统提供了一个提示,在启动时适当地设置状态栏的方向。

清单1:以横向模式启动您的应用程序

 <key>UIInterfaceOrientation</key> <string>UIInterfaceOrientationLandscapeRight</string> 

更多信息请点击这里