Question

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

Was it helpful?

Solution 2

Sorry for the delay, to make it works you must apply UIBarButtonItem the in the method viewDidAppear

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top