Direct UINavigationBar Button Not Displaying

I use the following function through a notification to load the right button on my UINavigationBar, and although I can trace the button and check that it is highlighted, it does not display ... any ideas?

EDIT 6/6/2011, 2:42 PM

So, something interesting ... the width always reports 0.0 ...

- (void)showRightBarButton:(id)sender
{
    NSLog(@"Showing button");
    UIBarButtonItem *button = [[UIBarButtonItem alloc]
                               initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
                               target:self
                               action:@selector(showPI:)];
    [button setTitle:@"This Button"];
    self.navigationItem.rightBarButtonItem = button;
    //[[self.navigationItem rightBarButtonItem] setWidth:50];
    NSLog(@"Button width is %f.", self.navigationItem.rightBarButtonItem.width);
    [button release];
}
+5
source share
2 answers
[self.view setNeedsDisplay];

. . , , . , , , . , UINavigationBar , ?

, :

- (void)showRightBarButton:(id)sender
{
    NSLog(@"Showing button");
    UIBarButtonItem *button = [[UIBarButtonItem alloc]
                             initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
                                                  target:self
                                                  action:@selector(showPI:)];
    self.navigationItem.rightBarButtonItem = button;
    [button release];
}

EDIT: . 0.0, .

, . , , .

+4

, NSNotification, . ? , ?

-init, , , -viewDidLoad, .

-viewDidLoad.

0

All Articles