If I have some flow of my application like this..
navigation(vc1) --pushed--> vc2 --present--> navigation(vc3) --push--> vc4 --push--> vc5
how to dismiss to vc2 ?
If I have some flow of my application like this..
navigation(vc1) --pushed--> vc2 --present--> navigation(vc3) --push--> vc4 --push--> vc5
how to dismiss to vc2 ?
You can use popToViewController
:
Basic setup:
let nav = UINavigationController()
let vc1 = UIViewController()
vc1.title = "vc1"
let vc2 = UIViewController()
vc2.title = "vc2"
let vc3 = UIViewController()
vc3.title = "vc3"
let vc4 = UIViewController()
vc4.title = "vc4"
nav.viewControllers = [vc1,vc2,vc3,vc4]
Then pop to vc2
(which is at index 1
in the array):
let vcs = nav.viewControllers
nav.popToViewController(vcs[1], animated: true)
//OR, if you still have a reference to the view controller
nav.popToViewController(vc2, animated: true)