How to change the back button text on a UINavigationController

- by

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

If you enjoy my content, please consider supporting me on Ko-fi. In return you can browse this whole site witout any pesky ads! More details here.

Add your voice!

This site uses Akismet to reduce spam. Learn how your comment data is processed.