get black screen when switch view controller with XCode storyboard
-
09-12-2019 - |
Question
I am writing a simple app with a tab bar controller, and two tabs. The first tab will switch to another UITableViewController, which works fine. The second tab should switch to a view controller, which inherits from UIViewController, but it just shows black screen.
And I hook on ViewDidLoad, ViewDidAppear functions in the destination UIViewController, I found it is loaded well. But it just shows me a black screen. Any idea of what happen here? And how to fix it?
Solution
remove the empty implementation of - (void)loadView
from your viewController.
Since you load your view from a nib (in your case storyboard) you don't need to construct your view in code (i.e. implement loadView
).
It's there because of a bug (10887149) in the Xcode view controller template.
EDIT: This bug is fixed in Xcode 4.3.2. The template does no longer contain - (void)loadView