How to display storyboard? (iPhone)
-
28-10-2019 - |
Pergunta
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?
Solução
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>"];
Outras dicas
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.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow