0

I have 3 ViewControllers which segue operations is prepared more or less like this:

A --editview-> B ---showEdited->C

Where A is for list of objects B is for edit certain object and C is for showing edited object. At this moment when user is getting into C and trying to go back he is landing in edit state B instead of a list. Is it possible to close segue while performing to the new one? so that user will be back from C to A?

2 Answers2

1

I don't know if I understand correctly what you want to do but I hope this will work.

 if let firstVC = self.navigationController?.viewControllers[0] {
        self.navigationController?.popToViewController(firstVC, animated: true)
}
Axel
  • 768
  • 6
  • 20
0

Have you tried looking into unwind segues. Unwind segues help when you have a sequence of VCs, say 1 -> 2 -> 3, and an unwind segue takes you from 3 directly back to 1.

Try these links:

https://spin.atomicobject.com/2014/10/25/ios-unwind-segues/

What are Unwind segues for and how do you use them?

Hope this helped.

Community
  • 1
  • 1
Pannu
  • 96
  • 1
  • 12
  • It's best to summarize the contents of links when you post them, in case the pages you've linked to ever die or are no longer accessible. – Vemonus Jan 05 '17 at 19:15