Rodrigo
Rodrigo

Reputation: 12683

Can't rename or set new backBarButtonItem in UINavigationBar

I am using the XCode 4.3.2 and only want to set the text of my back button in my UINavigationBar.

Theh simple way is use

- (void)loadView {
    [super loadView];   
    self.navigationItem.backBarButtonItem =
    [[UIBarButtonItem alloc] initWithTitle:@"Back"
                                     style: UIBarButtonItemStyleBordered
                                    target:nil
                                   action:nil];
}

But id don't work. I open my Storyboard and see this:

back button disable

The back button is disable. So, I can't set the button or disable it. What can I do now?

Upvotes: 2

Views: 674

Answers (1)

Rob
Rob

Reputation: 437381

The backBarButton is used to set what the back button will say on your next view controller that you push, i.e. what the back button will say to let the user know how to get back to the current view controller. It's not used to control what the back button says on the current view controller. That's a common source of confusion.

In terms of what appears in IB, I'm not at all sure about what you're doing there. If you have a navigation bar, and you're pushing view controllers as the user goes through the app, there's nothing you need to do in IB (other than making sure you've got your navigation controller set up in your initial view). But there's no need to set up the back button in IB.

If you're trying to do something else, let us know, but that's the standard flow.

Upvotes: 1

Related Questions