I have a storyboard application with a navigation controller an two views controllers ('A', 'B').
In the Storyboard file: Navigationcontroller is the initial view controller. view controller 'A' is connected to the Navigationcontroller as rootcontroller. View controller 'B' is in storyboard but not connected to any view controller.
when i programmatically try to push view controller 'B' onto the navigationcontroller from inside view controller 'A' with:
B *controllerB = [[B alloc] init];
[self.navigationController pushViewController:controllerB animated:YES];
all i get is a transition to a black screen.
i checked the navigationController property in view controller A at runtime and it´s not nil. I do not instantiate the navigationController by myself, I let storyboard do the work (maybe that´s the problem). But I think it should be possible to "manually" push view controller to a navigation controller created by storyboard.
When I connect a segue from a button to 'B' in storyboard everything works fine. Only programmatically it does not work, only shows a black screen inside the navigationcontroller.
Maybe someone could help me with this issue.
The accepted answer didn't work for me. I was already using
instantiateViewControllerWithIdentifier
to navigate to view controller in different storyboard. I am using xcode7.2 and Swift.I am navigating from storyboard1, some view controller's button action. Destination is to initial Navigation controller of Storyboard2.
Still I get black screen.
The problem was storyboard2's Navigation controller linked to 1st view controller was linked via
show
.Solution:
Delete the link between Nav controller and 1st view controller. Now link it using
root view controller
. (Ctrl+Click on Navigation controller and drag it to the View controller and Select the option "root view controller")I haven't used storyboards yet so this answer is from a glance at the docs. It looks like you can't alloc/init a view controller from a storyboard. You need to use the
instantiateViewControllerWithIdentifier:
method of yourUIStoryboard
instance and then you can push the controller.