新的ViewControllers导致黑屏 [英] new ViewControllers causing Black screen
问题描述
我正在通过界面构建器添加新的视图控制器(场景)。我将它们放在画布上然后创建一个新的视图控制器子类( NewViewController
,这会创建两个fiels: NewViewController.h
和 NewViewController.m
)。然后我将身份检查器下的类设置为新添加的视图控制器( NewViewController
)。
I'm adding new view controllers (scenes) via the interface builder. I drop them on the canvas and then create a new view controller subclass (NewViewController
, this creates two fiels: NewViewController.h
and NewViewController.m
). I then set the "class" under the identity inspector to the newly added view controller (NewViewController
).
现在当我运行应用程序时,初始场景有一个带有segue到第二个场景的按钮(其中 NewViewController
是类)并且它没有加载新场景/看来,它只是黑色。我错过了一步吗?
Now when I run the app the initial scene has a button with a segue to the second scene (where NewViewController
is the "class") and it doesn't load the new scene/view, its just black. Am I missing a step?
如果我删除了类: NewViewController
,并将其放回初始视图controller( ViewController
)它显示页面就好了。
If I remove the class: NewViewController
, and put it back to the initial view controller (ViewController
) it displays the page just fine.
我正在关注本指南
推荐答案
删除Xcode的 loadView
方法在视图控制器中为您添加。当您以编程方式构建视图时,此方法是必需的,但在使用XIB或故事板时不需要此方法。
Remove the loadView
method that Xcode adds for you in the view controller. This method is required when you build you views programatially but is not needed when using XIBs or Storyboards.
这篇关于新的ViewControllers导致黑屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!