Let's say your C
controller is on top of the navigation controller's stack, and your B
controller is under that. E.g.
navigationController.viewControllers = @[ bViewController, cViewController ];
So the navigation controller is displaying cViewController.view
.
The navigation controller uses the second-to-top controller on its stack to configure the back button. In this case, it uses bViewController
to configure the back button. This is its algorithm:
UINavigationItem *navigationItem = bViewController.navigationItem;
UIBarButtonItem *barItem = navigationItem.backBarButtonItem;
if (barItem.image != nil) {
show a back button containing barItem.image;
}
else if (barItem.title != nil) {
if (barItem.title.length > 0) {
show a back button containing barItem.title;
} else {
don't show a back button;
}
}
else if (navigationItem.title != nil) {
if (navigationItem.title.length > 0) {
show a back button containing navigationItem.title;
} else {
don't show a back button;
}
}
else {
show a back button containing @"Back";
}