We had a similar problem trying to break out of a detailed view in a controller with a shared view.
Although I'm sure that the accepted answer works fine, another approach that I found works, and maybe a little cleaner, is to use unwinding.
I set up the spread on the main view I wanted to return to, then created a segue link to expand the segue from the view I wanted to pop (note: assumes you are using storyboards).
Make sure you set IBAction in the destination window that appears, which you are returning:
-(IBAction)prepareForUnwind:(UIStoryboardSegue *)segue { }
Connect the output to the segment in the storyboard to unwind. Sorry, I do not provide a lot of details on how to configure segue promotion, but many tutorials are available for this.
Then on your controller that you want to reject, connect segue to the expanding segment of the controller that you are returning to. Be sure to name segue.
Then when you click on the view controller you want to remove, just call
[self performSegueWithIdentifier:@"unwindSegueName" sender:self];
This worked very well, and it does not allow digging back into the navigation hierarchy, which may change.
Hope this is helpful to someone! Happy Holidays!
source share