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?
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.
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 :)
精彩评论