Victor Krusenstråhle Victor Krusenstråhle - 1 year ago 140
iOS Question

Swift programmatically navigate to another view controller/scene

I'm using following code to programmatically navigate to another ViewController. It works fine, but it some how hides the

navigation bar
. How do I fix this? (the navigation bar is created by embeding the
in the
navigation controller
if that matters.)

let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)

let nextViewController = storyBoard.instantiateViewControllerWithIdentifier("nextView") as NextViewController
self.presentViewController(nextViewController, animated:true, completion:nil)

Answer Source

You should push the new viewcontroller by using current navigation controller, not present.

self.navigationController.pushViewController(nextViewController, animated: true)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download