Objective C: Change title of back button in navigation bar

You need change title of the back button from view controller which call to next view controller:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (self.detailsViewController == nil) {
        self.detailsViewController = [[DetailsViewController alloc] initWithNibName:@"DetailsViewController" bundle:nil];
 }
 
 [self.navigationController pushViewController:detailsViewController animated:YES];
 
 [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

- (void)viewDidLoad {
 self.title = NSLocalizedString(@"root_tab_title_0", @"My Title");

 //Set title for back button to this controller
 self.navigationItem.backBarButtonItem =
  [[[UIBarButtonItem alloc] initWithTitle:@"My back button"
      style:UIBarButtonItemStyleBordered
      target:nil
      action:nil] autorelease];
}

No comments:

Post a Comment