George Penn.
George Penn.

Reputation: 413

iPhone pushViewController keep the right part of navigation bar

In an iPhone app I want to have a navigation button on the right side of the navigation bar of the root navigation controller. However this right button disappears every time I push another viewController on top of the navigation controller and the right slot becomes empty. How can I make sure it remains on its proper place. I am using Interface Builder.

The "View Controller Programming Guide for iOS", as I understand it, says that the new viewController I'm pushing has to have its navigationController property set to the current navigation controller, however this property is readonly. How can I achieve this?

Upvotes: 0

Views: 1050

Answers (1)

ipraba
ipraba

Reputation: 16543

This is the thing with Navigation controller

The left bar button is taken Automatically by the iOS for All viewControllers But you have to design the Rightbarbutton for the Specific ViewController

So for each ViewController in ViewDidLoad

UIBarButtonItem *rightCornerButton = [[UIBarButtonItem alloc] 
                                      initWithTitle:@"Client Profile" 
                                      style:UIBarButtonItemStylePlain target:self 
                                      action:@selector(onTouchRightBarButton:)];
[self.navigationItem setRightBarButtonItem:rightCornerButton];
[rightCornerButton release];

Upvotes: 3

Related Questions