Reputation: 851
I have the next code:
- (id) initWith...{
if (self == [super initWithNibName:@"EmptyViewController"
bundle:[NSBundle mainBundle]]){
...
back_btn = [[UIBarButtonItem alloc] initWithTitle:@"Back"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(backParentViewController)];
self.navigationItem.leftBarButtonItem = back_btn;
update_btn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
target:self action:@selector(refresh)];
self.navigationItem.rightBarButtonItem = update_btn;
self.title = [utils LabelFromKey:@"commons.nav-button.reports"];
self.navigationItem.title = [utils LabelFromKey:@"commons.nav-button.reports"];
}
But the rightBarButton is not visible.
I try to move the code to the viewDidLoad, and to set the buttons to the navigationController.navigationItem but doesn't show the button
self.navigationController.navigationItem.rightBarButtonItem = update_btn;
Any suggestions ¿?
Thank you
Upvotes: 2
Views: 1503
Reputation: 851
Sorry for the delay, to make it works you must apply UIBarButtonItem the in the method viewDidAppear
Upvotes: 0
Reputation: 80265
Eliminate the ivar update_btn
. Start your allocation in viewDidLoad
with
UIBarButtonItem *update_btn = [[UIBarButtonItem alloc] init...;
Assign the item with this statement:
self.navigationItem.rightBarButtonItem = update_btn;
[update_btn release];
Let me know if this works for you.
Upvotes: 1