Reputation: 5823
Looks like the Back button of UINavigationBar uses view controller's title as its title, and if the previous view controller does not have a title, it uses Back, but is there a way to customise the title of the back button, no matter what title does previous view controller has?
Thanks
Upvotes: 1
Views: 3314
Reputation: 5226
You need to create your own bar button item and assign it to the previous view controller navigationItem backBarButtonItem property, for example:
UIBarButtonItem *temporaryBarButtonItem = [[UIBarButtonItem alloc] init];
temporaryBarButtonItem.title = NSLocalizedString(@"MAIN", @"Back bar button item to go back to the main view controller");
self.navigationItem.backBarButtonItem = temporaryBarButtonItem;
Check the UINavigationItem class reference to make sure you put the codes above in the correct view controller, especially this part:
When this navigation item is immediately below the top item in the stack, the navigation controller derives the back button for the navigation bar from this navigation item.
Upvotes: 5