On a UIViewController instantiated by a UITabBarController, when I run the following code,
let destination = self.storyboard?.instantiateViewControllerWithIdentifier("test")
self.navigationController!.pushViewController(destination!, animated: true)
navigationController return nil. How can I get navigationController instance to push a view controller?
As @Paulw11 said, what was missing was embed the UIViewController in a navigation controller. To do that, drag-and-drop a Navigation Controller to the Storyboard and CTRL + drag from that Navigation Controller to the UIViewController, chosing the relationship root view controller.
Your source UIViewController instance needs to be embedded in a UINavigationController in the storyboard scene in order to provide a navigation controller instance to push to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With