Question

I have in a storyboard a managed container view. I have four views that the user can swipe around and around.

If a user does a double , double touch tap, I send them to a new controller. The question is, how do I take them back? I want a double double touch tap to send them back where they came from.

I can't use a segue back because I don't know what to link back to at the storyboard level. How do I change the destination of the segue to go back where we came from?

Was it helpful?

Solution

In this type of situation it is easiest to just define a generic "pop" unwind segue that all the view controllers will implement like so:

- (void)pop:(UIStoryboardSegue *)segue;

Then since each view controller has this unwind segue defined, the navigation controller will look at the navigation stack in reverse order and unwind to the first one that implements the desired segue. This will give your navigation stack full unwind capabilities.

The downside to this approach is you might need additional segues if you want to jump back to a particular view controller.

EDIT:

I just want to note this method works in Storyboard as well, just add an exit segue and hook up each view controller to pop:.

Hope this helps!

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