How to change the UINavigationController back button name?
Solution 1:
If you wish to do this programmatically, it can be done like this:
Objective-C
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:@"Custom"
style:UIBarButtonItemStyleBordered
target:nil
action:nil];
[self.navigationItem setBackBarButtonItem:backItem];
Swift
let backItem = UIBarButtonItem(title: "Custom", style: .Bordered, target: nil, action: nil)
navigationItem.backBarButtonItem = backItem
However, if you prefer using Interface Builder, just select the UINavigationItem that you wish to set the back button for, and navigate to the attributes inspector to change the back button's title.
NOTE: It is important to remember that you must configure this on the view controller that you would be returning to upon tapping the back button, not the currently visible view controller.
Solution 2:
There is an easy way of doing that in Interface Builder or Storyboarding. In the parent View Controller, just set the attribute "Back Button" of the navigation item to whatever title you want. Here is an example:
Villian's Tavern View will have "Back" as Back Button Title, like we just set in the attributes inspector of the parent's navigation controller (Best Bars).
Solution 3:
In viewWillAppear write this
self.navigationItem.title = @"List View";
And in ViewWilldisapper write this
self.navigationItem.title = @"Back";
It works without story boards.
Solution 4:
In my case it only worked running the code on the Main Thread, like so:
dispatch_async(dispatch_get_main_queue(), ^(void) {
self.navigationController.navigationBar.backItem.title = @"Custom Title";
});