views:

93

answers:

2

Hello guys!

Here's my code:

UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(rightButtonPressed)];
[self.navigationItem setLeftBarButtonItem:leftButton];
[leftButton release];

The 'self' class is inherited form an UINavigationController and is I presenting it from an other UIViewController with the 'presentModalViewController' method. What do you think? Why isn't displaying the left button?

+2  A: 

This code should be placed inside a view controller that is on the navigation controllers navigation stack, not a UINavigationController subclass.

Naviation items are properties of view controllers that will be placed in navigation controllers. You shouldn't be using the navigation item property of a navigation controller itself.

Jasarien
Thanks a lot! This is the answer! :)
Infinity
A: 

I have never used the setter for the menu items, I have always added the button to the menu bar. You might try that.

EDIT. I see that you are using a subclass -I missed that before-, if you are not referencing the navigation controller directly it may not work(obviously as it's not currently :)

Shadow