How to change the back button text on a UINavigationController

In Your Storyboard

I didn’t know the storyboard could do this, but it can:

Select the Navigation Bar in question, then check the Attributes Inspector:

Screen Shot 2013-03-03 at 19.19.25

In Code

To set the title in code, you need to address the self.navigationItem.backBarButton property of your view controller and pass it a new UIBarButtonItem. Here’s one way of doing it:

// set a different back button for the navigation controller
UIBarButtonItem *myBackButton = [[UIBarButtonItem alloc]init];
myBackButton.title = @"Custom Text";
    
self.navigationItem.backBarButtonItem = myBackButton;

Alternatively we can use a much longer init method which will set the title in one line:

// set a different back button for the navigation controller
UIBarButtonItem *myBackButton = [[UIBarButtonItem alloc]initWithTitle:@"My Text" style:UIBarButtonItemStyleBordered target:nil action:nil];
    
self.navigationItem.backBarButtonItem = myBackButton;

One Thing of Note

The back button (and its text) is only displayed in the NEXT view controller on the stack. So changing the back button in the detail view controller for example doesn’t change what’s displayed when the detail view controller is displayed. You must change it one step earlier, in the master controller’s navigation bar.

Screen Shot 2013-03-03 at 19.22.06





Jay is the CEO and founder of WP Hosting, a boutique style managed WordPress hosting and support service. He has been working with Plesk since version 9 and is a qualified Parallels Automation Professional. In his spare time he likes to develop iOS apps and WordPress plugins, or draw on tablet devices. He blogs about his coding journey at http://wpguru.co.uk and http://pinkstone.co.uk.