Breaking News
Home / iOS / iOS Snippets / How do you hide the back button in UINavigationController?

How do you hide the back button in UINavigationController?

Whenever a child view is pushed into the Navigation Controller, a back button on the top left of the page is displayed. Using this button the user can go back to the parent view. In some case we like not to display that button e.g. if we want to add an Cancel and Save button on the screen. Cancel acts like a back button and does not save anything. The Save button does validation and saves the data.In this case we don’t want user to simply touch the Back button and go back to parent view.

It is a single line of code that can be added in the viewDidLoad method to hide the back button in UINavgiation Bar is as follows.

  1. [ self.navigationItemsetHidesBackButton:YES animated:YES];
[pb_builder]

Check Also

EKCalendar – That account does not allow calendars to be added or removed

Usecase When I am trying to create a new Calendar programmatically using the EventKit API …

Leave a Reply