views:

35

answers:

2

Hi, everyone,

I want to ask a question about the iPhone application. I create the UINavigationController programmatically. And I use the UITableView to do the following thing. However, I don't know how to change the text of the text in the back button (see below, in this case is 'Plays') in code level? Thank you very much.

alt text

Link: http://www.freeimagehosting.net/image.php?02730817e4.png

A: 

You have to actually change the text of the back button before pushing the new view controller onto the stack.Otherwise the back button text will not be displayed.

Mahadevan S
@Mahadevan, thank you for your reply. And would you mind to show the code how to change it. Actually, it is what I what.
Questions
+1  A: 

To customize the back button you modify the view controller you are going back to. So you can either set the title for your "Plays" view controller:

- (void)viewDidLoad {
    // ...
    [self setTitle:@"Whatever"];
}

Or access the back button item:

- (void)viewDidLoad {
    // ...
    // target/action must be nil
    self.navigationItem.backBarButtonItem =
        [[[UIBarButtonItem alloc] initWithTitle:@"Whatever"
                                          style:UIBarButtonItemStyleBordered
                                         target:nil action:nil] autorelease];
}
Mike Weller
@Mike Weller, thank you for your reply. Is it possible the text of the title in navigation bar in rootViewController is different from the back button? I use the above method and it is the same.
Questions