I\'ve created a new navigation based iPhone app. I added this to the RootViewController.
- (void)viewDidLoad {
[super viewDidLoad];
UIBarButtonItem *add
There is actually another answer, which is not listed here, but might be very useful in many cases.
If you do not want to use UINavigationController, then self.navigationItem
is not an option for you.
UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"imageName"] style:UIBarButtonItemStyleBordered target:self action:@selector(action:)];
UINavigationItem *navigationItem = [[UINavigationItem alloc] initWithTitle:@"Bar Title"];
navigationItem.leftBarButtonItem = barButton;
[navigationBar pushNavigationItem:navigationItem animated:NO];
You might want that when creating lightweight UIViewController with bar and buttons, but do not want navigation overhead.