Search code examples
iosuinavigationbarbackbarbuttonitem

UINavigation back bar button


I have a UITableViewController as the root view controller of a UINavigationController.

When the app launches, there is no back bar button on the navigation bar. However, when I click on one of the table view cells, and then click back, a back bar button appears at the top of the original UITableViewController. I don't want this. How can I get rid of this?


Solution

  • On any view controllers that you don't want the back button to show, you can add this to the viewDidLoad method:

    [self.navigationItem setHidesBackButton:YES animated:NO];
    

    Alternatively, you can add this call in viewWillAppear:(BOOL)animated: if you want the change to be animated:

    [self.navigationItem setHidesBackButton:YES animated:animated];