ios 支持 iPhone 6 和 iPhone 6+ 的 iPad 纵向和横向不同的启动/启动屏幕图像
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25886703/
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
Supporting iPhone 6 and iPhone 6+ with different launch/splash screen image for iPad Portrait and Landscape orientations
提问by msk
What I understood from the available documentation and my testing is that
我从可用文档和我的测试中了解到的是
All existing Apps on iPhone 6 and 6 Plus run in compatibility mode, which means the APIs (like [UIScreen mainScreen].bounds) will return 320x568 (iPhone 5/5s) still in new iPhones (6/6 Plus) and all UI is scaled to the correct resolution by iOS.
To support iPhone 6/6Plus we need to create xib for Launch Screen (File->New->File->UserInterace->Launch Screen) and set the nib file as "Launch Screen File".
We can set different images for launch screen inside Launch screen nib file based on avaialble size classes. [Basically combinations of Any, regular and compact]
There is no way to differentiate between iPad in portrait and iPad in Landscape orientation (both are regular width regular height). Also there no way to differentiate between iPhone 4/4s and iPhone 5/s.
iPhone 6 和 6 Plus 上的所有现有应用程序都在兼容模式下运行,这意味着 API(如 [UIScreen mainScreen].bounds)将返回 320x568 (iPhone 5/5s) 仍在新 iPhone (6/6 Plus) 中,并且所有 UI 都是由 iOS 缩放到正确的分辨率。
为了支持iPhone 6/6Plus,我们需要为启动屏幕创建xib(文件->新建->文件->用户界面->启动屏幕)并将nib文件设置为“启动屏幕文件”。
我们可以根据可用的大小类在 Launch screen nib 文件中为启动屏幕设置不同的图像。[Any、regular 和compact 的基本组合]
无法区分纵向的 iPad 和横向的 iPad(两者都是常规宽度常规高度)。也没有办法区分 iPhone 4/4s 和 iPhone 5/s。
Is there a way I can support iPhone 6/6 Plus mode and also provide different launch images for iPad in portrait and iPad in landscape orientation?
有没有一种方法可以支持 iPhone 6/6 Plus 模式,并为 iPad 纵向和 iPad 横向提供不同的启动图像?
See also the similar problem here iOS 8 size classes for iPad landscape
另请参阅此处的类似问题iOS 8 size classes for iPad Landscape
回答by HorseT
You don′t have to use the launch screen file to make your App iPhone 6 / 6+ resolution compatible. Instead, you can select the LaunchImage asset as your Launch Images Source.
您不必使用启动屏幕文件来使您的 App iPhone 6 / 6+ 分辨率兼容。相反,您可以选择 LaunchImage 资产作为您的启动图像源。
It can be found at "App Icons and Launch Images" under your Targets:
它可以在您的目标下的“应用程序图标和启动图像”中找到:
If there is no LaunchImage asset just go to your Images.xcassets, make a secondary click (right click) and select "New Launch Image":
如果没有 LaunchImage 资源,只需转到您的 Images.xcassets,再次单击(右键单击)并选择“New Launch Image”:
The result is something like that:
结果是这样的:
Now just drag and drop your images for the specific resolutions you want to support and set the created LaunchImage asset as your source.
现在只需拖放您想要支持的特定分辨率的图像,并将创建的 LaunchImage 资产设置为您的源。
Hope it helps
希望能帮助到你
Cheers
干杯
回答by Alan Taylor
Asset catalogues currently work in landscape mode on iPhone on ios8. I had this reponse from apple support:
资产目录目前在ios8上的 iPhone 上以横向模式运行。我从苹果支持那里得到了这个回应:
"There is a bug involving launch images in asset catalogs and apps that launch in landscape on iPhone. Behind the scenes, the asset catalog compiler generates the same UILaunchImages key [1] in the final Info.plist that you would have added when you were specifying launch images manually. One of the sub-keys for each launch image specified under the UILaunchImages key is UILaunchImageOrientation which is always set to Portrait by the asset catalog compiler. This makes sense because apps on iPhone always launch in portrait orientation [2]. However, the iOS app launcher decides that since your UISupportedInterfaceOrientations only contains UIInterfaceOrientationLandscapeLeft and UIInterfaceOrientationLandscapeRight, it will only look for landscape launch images under the UILaunchImages key, of which it finds none.
Since there is no way to force the assets catalog compiler to specify
Landscape
for theUILaunchImageOrientation
sub-key of iPhone launch images, you should continue to specify your launch images by editing the information property list for your app as before."
“在 iPhone 上横向启动的资产目录和应用程序中存在一个涉及启动图像的错误。在幕后,资产目录编译器在最终 Info.plist 中生成相同的 UILaunchImages 键 [1]手动指定启动图像。在 UILaunchImages 键下指定的每个启动图像的子键之一是 UILaunchImageOrientation,它始终由资产目录编译器设置为 Portrait。这是有道理的,因为 iPhone 上的应用程序始终以纵向启动 [2]。但是,iOS 应用程序启动器决定,由于您的 UISupportedInterfaceOrientations 只包含 UIInterfaceOrientationLandscapeLeft 和 UIInterfaceOrientationLandscapeRight,它只会在 UILaunchImages 键下查找横向启动图像,但它没有找到。
由于无法强制资产目录编译器指定 iPhone 启动图像
Landscape
的UILaunchImageOrientation
子键,因此您应该像以前一样通过编辑应用程序的信息属性列表来继续指定启动图像。”