1
votes

Within my MainWindow.xib I have a setup like I have here below. I have a Tab Bar Controller with a Navigation Controller within the Tab Bar Controller. I can switch between the different Navigation Controllers and this all works.

What I am trying to do now is add a Right Bar Button Item to the Navigation Controller. I can't seem to use Interface Builder to drag and drop into the Navigation Controller. Is there a way to add a button to the Navigation Controller... either for specific Views or more preferably that persists throughout all views.

Tab Bar Controller 
    Tab Bar
    Navigation Controller
        Navigation Bar
        XXXXViewController
        Tab Bar Item
1

1 Answers

4
votes

You can do it programmatically in viewDidLoad of the controller where you want the right bar button and call the method in its selector depending on what you want that button to do .

UIBarButtonItem *comment = [[UIBarButtonItem alloc]
                            initWithBarButtonSystemItem:UIBarButtonSystemItemCompose
                            target:self
                            action:@selector(displayViewForPosts)];

self.navigationItem.rightBarButtonItem = comment;
[comment release];