我有一个可以纵向或横向启动的应用程序。我希望 Default.png 文件(应用程序启动时出现的启动图像)以正确的方向显示图像,所以我希望我需要使用两个不同的图像(不同的尺寸)。但是,我不知道如何让应用程序根据其启动方向选择要使用的图像。这可能吗?有什么方法可以知道应用程序的启动方向(在显示启动画面之前),然后选择正确的图像,还是我只需要让图像以其中一个方向横向旋转或图像这在 90 度旋转时无法区分?
2 回答
您可以专门为方向命名您的启动图像,并且每个图像都将针对该方向显示
Default-Portrait.png
Default-PortraitUpsideDown.png
Default-Landscape.png
Default-LandscapeLeft.png
Default-LandscapeRight.png
请参阅:http: //iosdevelopertips.com/ipad/ipad-managing-multiple-launch-images.html
在 iPhone 或 iPad 上加载应用程序时,可以显示启动图像以向用户提供应用程序正在加载的反馈。在 iPhone 上,一个 Default.png 文件就足够了,而在 iPad 上,需要预测设备以任何方向启动,包括倒置。
iPad 启动图像方向
为了处理各种方向选项,为 iPad 启动图像创建了一个新的命名约定。iPad 的屏幕尺寸为 768×1024,注意在高度之后的尺寸中考虑了 20 像素的状态栏。
文件名、尺寸
Default-Portrait.png * (768w x 1004h)
Default-PortraitUpsideDown.png (768w x 1004h)
Default-Landscape.png ** (1024w x 748h)
Default-LandscapeLeft.png (1024w x 748h)
Default-LandscapeRight.png (1024w x 748h)
Default.png (Not recommended)
如果您没有指定 Default-PortraitUpsideDown.png 文件,则此文件优先。
如果您没有指定 Default-LandscapeLeft.png 或 Default-LandscapeRight.png 图像文件,此文件将优先。尽管您可以包含 Default.png 文件,并且如果没有指定其他文件,它将被使用,但我认为包含应用程序所需的所有相关图像是最佳实践。
另请参阅 apple.com:https://developer.apple.com/library/content/qa/qa1588/_index.html , “提供启动图像”。
笔记:
仅限 iPhone 的应用程序:
仅限 iPhone 的应用程序可能只有一个启动图像。
并且:(Apple)为不同方向提供启动图像,(Apple)启动图像类型
EDIT 28/06/2014: This answer is from 2011 and as pointed out by @AlexShaffer: "These resolutions listed above are out of date for iOS 7. Launch images for iOS 7 include the status bar area. You should probably also use image catalogs for iOS 7 instead of using images with a naming convention: https://developer.apple.com/library/ios/recipes/xcode_help-image_catalog-1.0/AddingLaunchImagestoanAssetCatalog/AddingLaunchImagestoanAssetCatalog.html"