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?
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?
You need to create a custom button on the navigation controller. Put the following code in the viewDidLoad in your Root View Controller:
UIBarButtonItem * tempButtonItem = [[[ UIBarButtonItem alloc] init] autorelease];
tempButtonItem .title = @"Back";
self.navigationItem.backBarButtonItem = tempButtonItem ;
By setting the navigation bar button on the Root View Controller, the pushed view shows the appropriate back button.
You can actually set the title on the main view controller's navigationItem's title. Basically each UIViewController has a little stub UINavigationItem which contains metadata about how that view should be referenced inside a UINavigationController. By default, that metadata just falls back to the UIViewController itself.
Assuming 'self' is the UIViewController of the view that's visible inside the UINavigationController, set:
self.navigationItem.title = @"My Custom Title"