For one of my view controller (extends UITableViewController), I need to configure its back button text to “Back”. But the back button still shows up with parent view controller’s title (the default).
- (void)viewDidLoad
{
...
self.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil] autorelease];
}
You need to set the back button on the view controller that pushed the class onto the stack e.g. the controller that created and pushed the class you are showing
The docs for View Controller Programming Guide for iOS suggest that the
UINavigationItems are kept in theNavigation Item Stackwhich provides the title and buttons for the current item on the stack.Importantly (I added bits in [])
Looking at the docs under the
Configuring the Navigation Item Objectsection there is a diagram which shows the stack and thebackItempointing to the item below the top item in the stack. In your case the top item in the stack would refer to theUINavigationItemfor the class you are showing and thebackItemwill be a pointer to the class that pushed it.NB
Look at that section in the docs an image is worth a thousand words