Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone: NavigationController NavigationBar Back button text

When I push a new ViewController onto a navigation controller stack the "back" button is the Title of the previous controller.

How can I change the text in the back button to "Back" instead of the default name-of-last-controller?

like image 482
Ian Vink Avatar asked Jan 13 '10 00:01

Ian Vink


2 Answers

This is the proper way to make a back button with something other than the previous' pages title

UIBarButtonItem *barButton = [[UIBarButtonItem alloc] init];
barButton.title = @"Your Title";

self.navigationItem.backBarButtonItem = barButton; 

Its to my understanding that:

self.navigationItem.backBarButtonItem.title = @"Your Title";

will make the Title of the navigation bar on the previous page this which is not what you want.

like image 96
Matt Avatar answered Oct 22 '22 07:10

Matt


I know, the question is very old, but I found a nice solution.

UIBarButtonItem *barButton = [[UIBarButtonItem alloc] init];
barButton.title = @"back";
self.navigationController.navigationBar.topItem.backBarButtonItem = barButton;

Works from childView! Tested with iOS 7.

like image 13
seniorbenelli Avatar answered Oct 22 '22 06:10

seniorbenelli