ios 如何为 iPhone 6 / 6 Plus Landscape Only 应用程序创建启动图像?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25926661/
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
How do I create launch images for iPhone 6 / 6 Plus Landscape Only Apps?
提问by Alex Argo
I've got an existing landscape only app that I'm trying to add iPhone 6 / iPhone 6 Plus support for. When I was supporting iOS 6 / 7 I simply used the default-named launch portrait images with a landscape image rotated into portrait (ie. for 4" screens I created a landscape 1136x640 and then rotated to create a 640×1136 launch image.)
我有一个现有的仅限横向的应用程序,我正在尝试添加对 iPhone 6 / iPhone 6 Plus 的支持。当我支持 iOS 6 / 7 时,我只是使用默认命名的启动纵向图像,并将横向图像旋转为纵向(即,对于 4" 屏幕,我创建了一个 1136x640 的横向,然后旋转以创建一个 640×1136 的启动图像。)
I'm trying to get something working for iOS 8 and iPhone 6 / 6+ and have not come up with something that works yet. Here are some things that I have tried:
我正在尝试让一些适用于 iOS 8 和 iPhone 6 / 6+ 的东西,但还没有想出一些有用的东西。以下是我尝试过的一些事情:
- Follow the pattern for 4" screen launch image convention. I created [email protected] and [email protected] images. This did trick the simulator to run at proper iPhone 6/6+ resolution but when launching, the 4" screen launch image is used, not the new ones I created.
- Use an Asset Catalog - I create portrait launch images for iPhone 6 and iPhone 6 Plus in a LaunchImages Asset, as well as a Landscape one for iPhone 6 Plus. The iPhone 6 Plus works, but iPhone 6 just shows a black screen. (There's no way to create a iPhone 6 landscape launch image in an asset catalog)
- Specify UILaunchImages array in Info.plist with entries for all screen sizes (see reference https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/uid/TP40009252-SW28). I get similar results to an Asset Catalog here. I can get iPhone 6 Plus landscape working but not iPhone 6 landscape.
- 遵循 4" 屏幕启动图像约定的模式。我创建了 [email protected] 和 [email protected] 图像。这确实使模拟器以正确的 iPhone 6/6+ 分辨率运行,但是在启动时,使用了 4" 屏幕启动图像,而不是我创建的新图像。
- 使用资产目录 - 我在 LaunchImages 资产中为 iPhone 6 和 iPhone 6 Plus 创建纵向启动图像,并为 iPhone 6 Plus 创建横向启动图像。iPhone 6 Plus 可以工作,但 iPhone 6 只显示黑屏。(无法在资产目录中创建 iPhone 6 横向启动图像)
- 在 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 横向运行。
回答by Alex Argo
I found a workaround that makes landscape only launch images work on iOS 8 GM. I ended up using the UILaunchImages array in Info.plist. The trick is to get image to show up that doesn't explicitly support landscape (iPhone 4/4S, iPhone 5/5S/5C, iPhone 6) you need to specify duplicate entries. See my example below. This is for a landscape only phone app that supports both orientations for iPad. iOS 7 will fallback to the default image names.
我找到了一种解决方法,可以使横向仅启动图像在 iOS 8 GM 上工作。我最终在 Info.plist 中使用了 UILaunchImages 数组。诀窍是让图像显示不明确支持横向(iPhone 4/4S、iPhone 5/5S/5C、iPhone 6),您需要指定重复条目。请参阅下面的示例。这适用于支持 iPad 两种方向的仅横向手机应用程序。iOS 7 将回退到默认图像名称。
All iPhone launch images need to be rotated into portrait orientation as usual EXCEPT for the iPhone 6 Plus launch image. It natively supports landscape orientation launch images, so you need to leave it's launch image in landscape orientation.
所有 iPhone 启动图像都需要像往常一样旋转为纵向,除了 iPhone 6 Plus 启动图像。它本机支持横向启动图像,因此您需要将其启动图像保留为横向。
Here are relevant bits of your Info.plist:
以下是您的 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>
回答by malhal
The pattern has changed for the iPhone 6 etc
iPhone 6 等的模式已经改变
iPhone 6 (750x1334):
iPhone 6(750x1334):
Default-375w-667h@2x~iphone.png
默认-375w-667h@2x~iphone.png
iPhone 6 Plus: (1242x2208)
iPhone 6 Plus:(1242x2208)
Default-414w-736h@3x~iphone.png
默认-414w-736h@3x~iphone.png
[email protected] (For Landscape)
Note if you support iPad then you must rename your iPad Default images to append ~ipad e.g. Default-Portrait~ipad.png to prevent the 6 plus from picking those up because those override the 3x image.
请注意,如果您支持 iPad,那么您必须重命名您的 iPad 默认图像以附加 ~ipad 例如 Default-Portrait~ipad.png 以防止 6 plus 拾取这些图像,因为它们覆盖了 3x 图像。
回答by ingaham
The following steps worked for me:
以下步骤对我有用:
- Add the images to the project (root directory or Resources folder) with the following nomination (I will describe them into the Portrait launchimages): Default.png (3.5 inch), [email protected] (4 inch), [email protected] (iPhone 6), [email protected] (iPhone 6plus).
- Go to the target settings, App Icons And Launch Images on the General tab -> Set the Launch Image Source to not use asset catalog ('Do not use asset catalogs').
- Remove the LaunchImage asset from your main image asset
- Go to the target settings, App Icons And Launch Images on the General tab -> Set the Launch Image Source to use asset catalog
- The XCode 6 is going to ask you about image asset migration from the existing images. Just click to 'Migrate'.
- 将图像添加到项目(根目录或资源文件夹)中,命名如下(我将在人像启动图像中描述它们):Default.png(3.5 英寸)、[email protected](4 英寸)、Default- [email protected] (iPhone 6),默认 [email protected] (iPhone 6plus)。
- 转到目标设置,“常规”选项卡上的“应用程序图标和启动图像”-> 将“启动图像源”设置为不使用资产目录(“不使用资产目录”)。
- 从主图像资产中删除 LaunchImage 资产
- 转到目标设置,常规选项卡上的应用程序图标和启动图像 -> 设置启动图像源以使用资产目录
- XCode 6 将询问您有关从现有图像迁移图像资产的问题。只需单击“迁移”即可。
And it worked for me for each kind of devices on iOS7, iOS8. Note: If you check the new LaunchImage asset, then you can see it is really strange. It seems to contain only a few image without the images with iPhone6 or iPhone 6plus resolution.
它适用于 iOS7、iOS8 上的各种设备。注意:如果你查看新的 LaunchImage 资产,那么你会发现它真的很奇怪。它似乎只包含一些图像,没有 iPhone6 或 iPhone 6plus 分辨率的图像。
回答by Amit Saini
For iPhone 6:
对于 iPhone 6:
750 x 1334 (@2x) for portrait
1334 x 750 (@2x) for landscape
纵向 750 x 1334 (@2x)
横向 1334 x 750 (@2x)
For iPhone 6 Plus:
对于 iPhone 6 Plus:
1242 x 2208 (@3x) for portrait
2208 x 1242 (@3x) for landscape
纵向 1242 x 2208 (@3x)
横向 2208 x 1242 (@3x)
or you can go through this link it may help you
或者你可以通过这个链接它可能会帮助你
http://matthewpalmer.net/blog/2014/09/10/iphone-6-plus-launch-image-adaptive-mode/
http://matthewpalmer.net/blog/2014/09/10/iphone-6-plus-launch-image-adaptive-mode/
回答by Nadzeya
If you are using only Images.xassets "Launch Screen File" should be empty. It helped me.
如果您只使用 Images.xassets,“启动屏幕文件”应该是空的。它帮助了我。
回答by janoside
This is a follow-up to @AlexArgo's answer that extends it so that landscape-only, iOS 9-supporting apps show appropriate launch images on iOS 9 iPhones. As with that answer, no asset catalog, storyboard, or xib is required.
这是@AlexArgo 的回答的后续,扩展了它,以便仅支持横向的 iOS 9 应用程序在 iOS 9 iPhone 上显示适当的启动图像。与该答案一样,不需要资产目录、故事板或 xib。
Without these additions, the behavior we saw was that launching our landscape-only app on an iOS 9 iPhone displayed the same image as for iOS 8, but the image was rotated 90-degrees clockwise and distorted by being stretched to the opposite-orientation's dimensions.
如果没有这些添加,我们看到的行为是在 iOS 9 iPhone 上启动我们的仅横向应用程序显示与 iOS 8 相同的图像,但图像顺时针旋转 90 度并通过拉伸到相反方向的尺寸而扭曲.
Pre-fix iOS 9 iPhone launch screen:
There are 2 parts to this solution:
此解决方案有两个部分:
- Add the below iOS 9 items to your
Info.plist
'sUILaunchImages
array beforethe iOS 8 items from @AlexArgo's answer. Add the new launch images referenced in the below iOS 9 items (eg.
Default-iOS9-568h
) to your app. The new launch images are actual"landscape"-orientation images (wider than they are tall), unlike the images referenced by @AlexArgo's iOS 8 items that started as landscape images but were then rotated to the portrait orientation before being added to the app. Note that both sets of images must remain in the app for this solution to work on iOS 8 and 9 simultaneously.<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>
- 在@AlexArgo 的回答中的 iOS 8 项之前,将以下 iOS 9 项添加到您
Info.plist
的UILaunchImages
数组中。 将以下 iOS 9 项目(例如
Default-iOS9-568h
)中引用的新启动图像添加到您的应用程序。新发布的图像是实际的“横向”方向图像(宽大于高),与@AlexArgo 的 iOS 8 项目引用的图像不同,这些图像以横向图像开始,但在添加到应用程序之前被旋转为纵向。请注意,这两组图像必须保留在应用程序中,此解决方案才能同时在 iOS 8 和 9 上运行。<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>
回答by Myrddin
To work with ipad (landscape and portrait mode), you need to add the UILaunchImages~ipadkey in your info.plist :
要使用 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>
回答by nheagy
For all iPhones except the plus, there is no separate launch screen for landscape-only apps. You set the orientation in the plist as Deepak described, and then you set your portraitlaunch screen to the rotated version of your landscape launch screen.
对于除 plus 之外的所有 iPhone,仅横向应用程序没有单独的启动屏幕。您按照 Deepak 的描述在 plist 中设置方向,然后将纵向启动屏幕设置为横向启动屏幕的旋转版本。
This is how it's always been, and the only thing that has changed is that the plus now supports a separate, distinct landscape launch screen. All other devices still only support portrait launch screens regardless of your app's starting orientation.
这就是它一直以来的样子,唯一改变的是 plus 现在支持一个单独的、独特的横向启动屏幕。无论您的应用程序的启动方向如何,所有其他设备仍然只支持纵向启动屏幕。
回答by PKCLsoft
What I've done is change my project to NOT use an asset catalog for launch images, and use the old technique for iOS7 and earlier. This gets the launch images working for iOS7 and earlier.
我所做的是将我的项目更改为不使用资产目录来启动图像,并使用适用于 iOS7 及更早版本的旧技术。这使启动图像适用于 iOS7 及更早版本。
To get them also working for iOS8 so that you can get the correct resolution, and have your app recognised as being built for the new iPhone 6/+, you also need to create a new LaunchImage XIB and tell Xcode to use that.
为了让它们也适用于 iOS8,您可以获得正确的分辨率,并让您的应用程序被识别为是为新的 iPhone 6/+ 构建的,您还需要创建一个新的 LaunchImage XIB 并告诉 Xcode 使用它。
What appears to happen is that launching the app on an iOS8 device uses the new XIB technique, and launching it on an iOS7 or earlier device uses the images you've grown to know and love.
似乎发生的情况是,在 iOS8 设备上启动应用程序使用新的 XIB 技术,而在 iOS7 或更早版本的设备上启动它使用您逐渐了解和喜爱的图像。
This for me seems to work. It's ugly IMO, but it works.
这对我来说似乎有效。这是丑陋的国际海事组织,但它的工作原理。
Hope this helps some people.
希望这可以帮助一些人。
回答by wagashi
you just add [email protected], then it will fix itself for Landscape as well. I've also a landscape-only app for iPhone 6 and iPhone 6 Plus and it works without problems!
您只需添加 [email protected],然后它也会为横向修复自身。我还有一个适用于 iPhone 6 和 iPhone 6 Plus 的横向应用程序,它运行没有问题!