문제

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 :)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top