How to return to the previous uinavigationcontroller


I would like to know if there is a way to go back to the previous UINavigationController so that I do not have to re-instantiate it, this is because I want to pass a variable to the previous view controller and then go to it without need to instantiate it again.

The thing is that the current view controller is inside a new UINavigation , I leave the code:

let vc:TotalSlidesViewController = self.storyboard?.instantiateViewControllerWithIdentifier("TotalSlidesViewController") as! TotalSlidesViewController
vc.previousVC = self
navigationVC = UINavigationController.init(rootViewController: vc)
self.navigationController?.presentViewController(navigationVC, animated: true, completion:nil)

And then when I want to go back in the Second ViewController:


Here would go the part where I have to go back, if I do popToRoot it does not work since I'm already at the beginning of the current UINavigationController .

asked by user4264 14.03.2016 в 11:23

1 answer


The answer would be:

self.navigationController?.dismissViewControllerAnimated(true, completion: nil)
answered by 14.03.2016 в 11:27