Xcode Nav Buttons

You can change the title of the back button and put a rightBarButton on the screen using the following code.

In the – (void)viewDidLoad method, just after [super viewDidLoad]; put this code.


UIBarButtonItem *backButton =
    UIBarButtonItem *backButton =
    [[UIBarButtonItem alloc] initWithTitle: @"Main"
                                     style: UIBarButtonItemStyleBordered
                                    target: nil
                                    action: nil];
    self.navigationItem.backBarButtonItem = backButton;


    UIBarButtonItem *helpButton =
    [[UIBarButtonItem alloc] initWithTitle: @"Help"
                                     style: UIBarButtonItemStylePlain
                                    target: self
                                    action: @selector(goToHelp)];
    self.navigationItem.rightBarButtonItem = helpButton;
    self.navigationItem.rightBarButtonItem.enabled = YES;

If you don’t want a back button use this


[self.navigationItem setHidesBackButton:YES];

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.