Search code examples
iphoneiosuinavigationcontrollerpushviewcontroller

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?


Solution

  • 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];