How to display storyboard? (iPhone)
-
28-10-2019 - |
Frage
I've created a storyboard that I want to display using my UINavigationController
. The initial view in the storyboard
is a UITableViewController
so I have created a subclass of UITableViewController
and set the class on the storyboard to match it.
I then try to display the storyboard like so:
StoryBoardView *newView = [[StoryBoardView alloc] init];
[self.navigationController pushViewController:newView animated:YES];
However my view is not shown for some reason. Please can someone help me?
Lösung
When you push the view controller, you need to instantiate the view controller from within your storyboard, not just alloc/init a new instance.
StoryBoardView *newView = [[self storyboard] instantiateViewControllerWithIdentifier:@"<ViewControllerIdentifier>"];
Andere Tipps
Have you tried when viewing the storyboard, select your very first controller and tick 'Is Initial View Controller'? That should start your app with that controller.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow