简体   繁体   中英

Go back for 2 segues while clicking at back button

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 ?

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)
}

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM