设置为情节提要文件时,启动屏幕为黑色 [英] Launch screen is black when set to a storyboard file

查看:102
本文介绍了设置为情节提要文件时,启动屏幕为黑色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用情节提要来获取启动图像中导航栏的正确高度.

但是,在稍微自定义视图控制器之后,它现在显示黑屏而不是启动图像.

However, after customizing the view controller a bit, it now displays a black screen instead of a launch image.

当我将其设置为全新的视图控制器时,一切都很好.看来原来的视图控制器现在处于故障状态.

When I set it to a brand new view controller, everything is fine. It seems like the original view controller is now in a bad state.

我该如何解决?

(我正在Xcode 6.2上运行iOS 8.2模拟器.)

(I'm running iOS 8.2 simulator on Xcode 6.2.)

推荐答案

这种情况下的问题是在视图控制器上设置了插座.

The problem in this case was that there was an outlet set on the view controller.

如果初始视图控制器上有任何出口(或者,如果初始视图控制器是导航控制器,则为根视图控制器),系统将不会渲染任何启动图像,而是显示黑屏.

If there are any outlets on the initial view controller (or, if the initial view controller is a navigation controller, the root view controller), the system will not render any launch image, and instead show a black screen.

对于我来说,我将目标的主界面设置为与启动屏幕文件相同的值(均设置为情节提要).一旦启动了真正的应用程序,我就需要对视图进行一些操作(因此,为什么要使用IBOutlet).删除IBOutlet之后,我可以使用-[UIView viewWithTag:]操纵视图.

In my case I have my target's Main Interface set to the same value as the Launch Screen File (both set to storyboards). Once it launches the real app, I want to manipulate the view a bit (hence why I had an IBOutlet). After deleting the IBOutlets, I was able to manipulate the view by using -[UIView viewWithTag:].

注意:当使用视图控制器为启动屏幕渲染图像时,该类中的任何代码都不会被调用(例如,永远不会调用-[UIViewController viewDidLoad]).另一方面,当视图控制器用于主界面时,代码将按您期望的那样正常执行.

Note: When the view controller is being used to render an image for the launch screen, none of the code in the class is called (e.g. -[UIViewController viewDidLoad] is never called). On the other hand, when the view controller is being used for the Main Interface, the code is executed normally, as you would expect.

这篇关于设置为情节提要文件时,启动屏幕为黑色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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