Question

Below you see my view hierarchy. The view with green color is the last view. From the last view I want show another view, indicated by the black arrow.

However when the user wants to navigate back from this view, the initial view (indicated by yellow arrow) should be presented. I could make a segue from last view to the "black arrow" view. But how can I show the initial view (yellow arrow) when user goes back?

enter image description here

Was it helpful?

Solution

METHOD1: Well, then it depends on your segues, if all of them is push type, then your green VC will be embedded too. If it is, then you can navigate through all your hierarchy via [self.navigationController popToViewController:desiredViewController animated:YES].

Here what this method does: Pops view controllers until the specified view controller is at the top of the navigation stack.

Reference: UINavigationController Class

METHOD2: If you still want to use modal presentation, you could create weak delegate property to bind your greenController with controller, which presented it (or use NSNotificationCenter to listen your dismiss modal view controller event). Once user pressed on dismissing, controller which presented greenController redirects it with no animation to yellow one. It will create the illusion that once you dismissed your controller underneath is yellowController. However, it still depends on your transition needs between yellow-green controllers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top