Reputation: 16051
How do i make it show the back button, with the title "Back"? It shows perfectly well if the previous view controller has a title.
Upvotes: 2
Views: 2876
Reputation: 2528
Simplest solution is in viewDidLoad of the view that is about to push a new one, do the following:
UIBarButtonItem *backBarButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:nil action:nil];
self.navigationItem.backBarButtonItem = backBarButton;
[backBarButton release]
Works perfectly, no questions asked.
Upvotes: 4
Reputation: 10733
You can also try to set the title before pushing the new view controller. For example:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[self setTitle:@"back"];
// Push new view controller...
}
and then set it back to @"" in your -viewWillAppear
.
Upvotes: 0
Reputation: 94773
You can set the backBarButtonItem property of the previous viewController. So if you are have one viewcontroller "A" and you push a viewController "B". The back button will be the button backBarButtonItem on the "A" view controller.
Upvotes: 2