4
votes

Is it possible to make the default navigation 'Back' button call an unwind segue? I know it's possible with a standard button by dragging it onto the green exit icon, but the default navigation 'Back' button is not visible on the storyboard.

There seems to be an example of this in the iPhone's Contacts app. After you add a new contact, it takes you to a screen displaying all the entered information, here the '< Back' button appears to perform a unwind segue to the Contacts list screen. Anyone know how it's done?

I realise I can add a standard button and make it invoke the unwind segue, but it doesn't have the '<' symbol which I would like to have.

1

1 Answers

0
votes

As I know there is no way to set an another action for default back button. I spent much time trying to do this. You can make a custom button that looks like default but default button can be changed in next iOS version. For unwind action you can just edit a viewControllers array of your navigation controller. For example, you have 4 view controllers in the stack of your navigation controller and you want to go back from 4th to 2nd. Paste this in viewDidLoad: method of 4th controller :

NSMutableArray *viewControllers = [self.navigationController.viewControllers mutableCopy];
[viewControllers removeObjectAtIndex:2];
self.navigationController.viewControllers = viewControllers;