How to hide the "back" button in UINavigationController? How to hide the "back" button in UINavigationController? ios ios

How to hide the "back" button in UINavigationController?


I just found out the answer, in a controller use this:

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

And to restore it:

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

--

[UPDATE]

Swift 3.0:

self.navigationItem.setHidesBackButton(true, animated:true)


Add this Code

[self.navigationItem setHidesBackButton:YES];


In addition to removing the back button (using the methods already recommended), don't forget the user can still 'pop' to the previous screen with a left-to-right swipe gesture in iOS 7 and later.

To disable that (when appropriate), implement the following (in viewDidLoad for example):

 if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)     self.navigationController.interactivePopGestureRecognizer.enabled = NO;