By default the UINavigationBar on a UINavigationController has a back button that has a little arrow on the side pointing to the left.  Unfortunately you can’t override this button, you can’t hook into it’s events or change it’s appearance.  Some of us, unfortunately need to be able to do this.  If you are one of these people then this is the article for you.

The trick to changing what the button does (you can change what it says by default), is to realize that you can’t.  I am not trying to be obtuse here, but it is true, you can’t do much to the default back button.  What you can do is simply put another button in it’s place.

– (void) viewDidLoad

// change the back button to cancel and add an event handler
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:@”Cancel”


self.navigationItem.leftBarButtonItem = cancelButton;
[cancelButton release];

– (void) handleBack:(id)sender

//Do your special code here

//done with your code

// pop the controller – the default action
[self.navigationController popViewControllerAnimated:YES];


As you can see above, all you need to do is set the leftBarButtonItem of the controller and it will hide the back button. The selector handleBack now handles the back event and you need to then manually pop the view controller off the UINavigationController’s stack. You can implement any of your own code in there, even blocking leaving the page.

I hope this helps some people out there.

Here is the full article that I was inspired by, I have just presented the data on that site in what I feel is a more concise format: