Search code examples
iosswiftuinavigationcontrolleruinavigationbarsegue

Redirect User to Specific ViewController - Swift 4


I'm trying to redirect users to the correct page after deletion of the place.

enter image description here

navigationController?.popToRootViewController(animated: true)

This will work, if I want to redirect to the root.

navigationController?.popViewController(animated: true)

This will work if I want to redirect to the previous

BUT in my case, I want to redirect to a specific page that not the root or the previous one.

How would one go about and do something like this in iOS ?


Solution

  • If you now the position in your stack you can also use

    self.navigationController?.popToViewController(self.navigationController!.viewControllers[1], animated: true)