Saketram Durbha Saketram Durbha - 1 year ago 214
Swift Question

Segue Out of Navigation Controller

I am trying to leave the initial view controller, and go into the blank view controller. That is fine, but that would make the blank view controller also part of the navigation controller, which is not what I want. I want to segue out of the view controller.

In the view controller I try to segue out of, it pops it self, and when I try the method in the view will appear of the target view controller,

returns itself, but
doesn't work

enter image description here

Answer Source

If you have a navigationController do


Otherwise do

self.dismissViewControllerAnimated(false, completion: nil)


Go to your Storyboard, select the ViewController you want to navigate to and add a storyboard id. Make sure the click "Use Storyboard ID" enter image description here

Go to the class you want to navigate from and add the following code

let storyboard = UIStoryboard(name: "Main", bundle: nil)
// vc is the Storyboard ID that you added
// as! ... Add your ViewController class name that you want to navigate to
let controller = storyboard.instantiateViewControllerWithIdentifier("vc") as! ViewController
self.presentViewController(controller, animated: true, completion: { () -> Void in

Add this code in the action that you use when you want to navigate.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download