I have view controller which is inherited from UINavigationController
.
On viewDidLoad
I want to set rightBarButtonItem
.
I do following.
UINavigationItem* navItem = self.navigationItem;
UIButton* btnOptionsView = [[UIButton alloc] init];
[btnOptionsView setImage:[UIImage imageNamed:@"options.png"]
forState:UIControlStateNormal];
[btnOptionsView sizeToFit];
UIBarButtonItem* btnOptions = [[UIBarButtonItem alloc] initWithCustomView:btnOptionsView];
navItem.rightBarButtonItem = btnOptions;
but the button is invisible, in debug mode I have noticed that btnOptions.width
is 0, and also I can't set the title for navItem
, something like this
[navItem setTitle:@"title"]
does not change the title of UINavigationItem
.