启动屏幕的行为与启动图像完全相同 [英] Launch Screen that behaves exactly like Launch Image

查看:119
本文介绍了启动屏幕的行为与启动图像完全相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了让iPad Pro在发布时使用全分辨率,我们必须使用启动屏幕文件



之前我从未使用过启动屏幕XIB / Storyboard,因为我的应用程序向后兼容iOS 7.通常我使用一个 LaunchImage资产目录以限定每个设备维度和启动方向的特定静态图像。



现在我正在尝试定义一个启动屏幕文件,其作用类似于LaunchImage资产目录,但我是努力做到这一点。特别是:



1)我没有看到根据设备的确切大小选择不同的UIImage的好方法,例如:向iPhone 4S用户显示一个图像,向iPhone 5用户显示另一个图像。



2)我没有办法为iPad Portrait和iPad Landscape选择不同的UIImage观点。大小类似乎认为iPad Portrait和iPad Landscape都是Regular宽度和Regular高度,因此任何出现在iPad Portrait上的UIImage也会出现在iPad Landscape中。

解决方案

系统在启动应用程序之前加载启动文件,这会对它可以包含的内容产生一些限制(其中一些可能会迫使你回到静态图像文件): / p>

1.应用程序尚未加载,因此视图层次结构不存在,系统无法调用您在应用程序中可能具有的任何自定义视图控制器设置代码(例如viewDidLoad )



2.您只能使用标准UIKit类,因此您可以使用UIView或UIViewController,但不能使用自定义子类。如果您尝试设置自定义类,您将在Xcode中收到非法配置错误。



3.启动文件只能使用基本的UIKit视图,如UIImageView和UILabel。您无法使用UIWebView。



4.如果您使用的是故事板,则可以指定多个视图控制器,但还有一些限制。例如,您可以在导航或标签栏控制器中嵌入视图控制器,但更复杂的容器类(如UISplitViewController)不起作用(至少尚未使用)。



5.Localizing启动文件目前似乎没有任何效果。始终使用基本本地化,因此您可能希望避免启动屏幕上的文本。



6.您无法为iPad和iPhone指定不同的启动文件。如果您为这些设备设置了明显不同的界面,这可能会出现问题,因为您可以使用自动布局和尺寸类别来实现这一点。



请注意,如果您是部署到iOS 7,您仍然需要包含静态启动图像文件。您可以包含启动图像文件和静态启动图像。运行iOS 8的iPhone 6等设备将使用启动图像文件,而iOS 7设备将回退到启动图像。


In order to get iPad Pro to use full resolution at launch, we have to use a Launch Screen File.

I've never used a Launch Screen XIB/Storyboard before, because my app is backwards compatible to iOS 7. Normally I use a LaunchImage asset catalog to define a specific static image for each device dimension and launch orientation.

Now I'm trying to define a Launch Screen File that acts like a LaunchImage asset catalog, but I'm struggling to do it. In particular:

1) I don't see a good way to select a different UIImage depending on the exact size of the device, e.g. show one image to iPhone 4S users and another image to iPhone 5 users.

2) I don't see a way to select a different UIImage for iPad Portrait and iPad Landscape views. Size classes seem to think that both iPad Portrait and iPad Landscape are "Regular" width and "Regular" height, so any UIImage that would show up on iPad Portrait will also show up in iPad Landscape.

解决方案

The system loads the launch file before launching the app which creates some constraints on what it can contain (some of which may force you back to static image files):

1.The app is not yet loaded so the view hierarchy does not exist and the system can not call any custom view controller setup code you may have in the app (e.g. viewDidLoad)

2.You can only use standard UIKit classes so you can use UIView or UIViewController but not a custom subclass. If you try to set a custom class you will get an Illegal Configuration error in Xcode.

3.The launch file can only use basic UIKit views such as UIImageView and UILabel. You cannot use a UIWebView.

4.If you are using a storyboard you can specify multiple view controllers but there are again some limitations. For example you can embed view controllers in a navigation or tab bar controller but more complex container classes such as UISplitViewController do not work (at least not yet).

5.Localizing the launch file does not currently seem to have any effect. The base localization is always used so you will probably want to avoid text on the launch screen.

6.You cannot specify different launch files for iPad and iPhone. This may be a problem if you have significantly different interfaces for those devices as there is only so much you can do with auto layout and size classes.

Note that if you are deploying to iOS 7 you will still need to include the static launch image files. You can include both a launch image file and static launch images. Devices such as the iPhone 6 running iOS 8 will use the launch image file whilst iOS 7 devices will fallback to the launch images.

这篇关于启动屏幕的行为与启动图像完全相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆