How can I unwind through multiple view controllers without displaying each one sequentially?
I have 3 view controllers, let's call them A, B, and C.
A uses presentViewController to present B, and B does the same with C. When I use an unwind method from C, first C vanishes, showing B, and then B vanishes, showing A. How can I get it to return to A directly, without ever displaying B?
Asked
Active
Viewed 241 times
3

Sid Mani
- 369
- 3
- 9
-
I am seeing the exact same behavior with iOS 11 and Xcode 9.3. Segue from A to B, then B to C. Unwinding from C to A shows a brief flash of B. The reference from @CodeBender does not address this problem. I worked around it by bringing a neutral background view to the foreground in `B.viewDidDisappear()`. This only works, of course, if the neutral view blends in with A's background. See a similar question at https://stackoverflow.com/questions/26785511/how-to-unwind-through-multiple-views-without-displaying-intermediate-views/26786895. – Andrew Duncan Apr 12 '18 at 16:35
1 Answers
2
How an Unwind Segue Determines its Destination View Controller
When an unwind segue is initiated, it must first locate the nearest view controller in the navigation hierarchy which implements the unwind action specified when the unwind segue was created. This view controller becomes the destination of the unwind segue. If no suitable view controller is found, the unwind segue is aborted.
This link contains information for setting up the unwind segue process as well.

CodeBender
- 35,668
- 12
- 125
- 132
-
1The link seems to suggest overriding canPerformUnwindSegueAction. I tried that, but it does not change anything. The problem isn't the destination view controller, rather that it shows the in-between view controller while performing the unwind. – Sid Mani Jun 30 '16 at 05:28
-
I'm seeing this also. Would appreciate if you or anyone else has found a solution or workaround. – Andrew Duncan Apr 11 '18 at 23:13