I have 3 viewControllers
: A, B and C.
A has a segue to B and A also has a segue to C.
If I'm currently in C, how do I segue over to B?
Note; I need to keep A active because once I'm in B, I need to be able to unwind back to A.
The following solution would be nice if I could unwind from C to A and then push to B without showing A in the process, but I can't get this to work, and no-one has provided a solution.
Chain two segues to look like one
Note; I'm not using a
UINavigationController
. I've tried simply pushing from C to B but then I'm not able to deallocate C. Calling unwind on C at any point during this process gives weird behaviour where A might appear on screen at some point.
Does anyone have a solution to this?
There is plenty of way to accomplish what you want.
I would do something really easy: that is to add an unwind segue (it's explained above how to add one) to exit to the first A vc, and add a custom segue (no matter which one) between B and C (that you simply create with the storyboard).
You start in A, then:
self.dismiss
, your using your exit segue. self.dismiss
or you can come back to A using the exit segue. To add un unwind segue, you must add a function to your first VC of the type:
@IBAction func unwindToA(segue: UIStoryboardSegue)
Then, in the storyboard when you are creating your segue on the your B view controller (using control+drag), start to drag from the VC icon (on the top of the screen) to the exit icon. Then, you will see appear a new segue, named 'unwindToA', which will take you back to your first VC: A.
To create your segue from B to C, you can do by control+drag from the first to the second VC in your storyboard, and choose the type you prefer (or you can create a custom segue if those provided don't correspond to want you expect).
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.