0
votes

Unwind segue dismissing two view controllers when the presenting view controller is a UIViewController presented by a child of tabbarController. Here's the structure:

tabBarController (root) -> child(first tab) -> MiddleViewController -> TopViewController

When I perform segue(unwind) from TopViewController, it gets dismissed and dismisses the MiddleViewController. Would it be because the presentingViewController of middleViewController is a child of the tabBarController? The function with segue parameter is indeed inside MiddleViewController. What would be the problem?

The TopViewController presentation style is .OverCurrentContext

1
Unclear. If MiddleViewController is a child of the tab bar controller, it cannot be “dismissed”, because it was never presented. What actually happens? Is it that everything goes black? If so did you switch to a different tab and come back? If so that is a well known bug; you must not let the user switch tabs while a tab is presenting another view controller. - matt
Actually, a child from tabbarController presented the MiddleViewController. When the unwind segue is performed from topViewController, the top and middle ViewController both get dismissed and I get back to the first tab again. - Mariela
Then you've hooked up the unwind segue incorrectly. If you do it right, you go back to where you want to go back to. The middle view controller is not dismissed automatically. - matt
Did you ever figure this out? I'm seeing the same behavior and thinking it's a bug in iOS? - GarySabo

1 Answers

0
votes

You've hooked up the unwind segues incorrectly. If you hook them up correctly, you go back to the middle view controller without dismissing it (until you ask to dismiss it).

As you can see here, we go First -> Middle -> Top and then Top -> Middle -> First in good order, one at a time.

enter image description here