Search code examples
swiftuinavigationcontrollerxcode-storyboard

Call a segue from another Navigation Controller


I'm trying to jump to a View that's on another Navigation Controller. You Can see the situation from my storyboard: enter image description here

Once I get to the the "Edit Sticker" view i want to go back to the "Create Pack" but I don't want that the "back" that I get once i click save takes me back to "Edit Sticker", it should take me to the view that's on the left of "Create pack". You can see the situation from this: enter image description here

What could be a good solution? How can I invoke a segue (the first one you see on the first picture on the top left, that's calling "Create pack") that's on another Navigation view controller?

UPDATE:
Tried setting it with one Navigation Controller: enter image description here

and programmatically setting this when I press Add:

self.navigationController?.popToRootViewControllerAnimated(true)

takes me back to the "1st View". I need to go the "Create pack" view.


Solution

  • How come the Edit Sticker view controller is on its on navigation controller?

    If the navigation hierarchy went Root -> Create Sticker -> Edit Sticker, you can call self.navigationController.popToRootViewController when the user clicks save.

    But if you want to control the segue, then use self.navigationController.popViewControllerAnimated(animated: Bool) as that just pops the view on top to give you more control.