Disable navigation bar’s back button

ios7uinavigationbaruinavigationcontroller

I'm trying to disable a navigation bar back button item (turning to gray and does not respond to touches).

I tried the following :

[self.navigationItem.backBarButtonItem setEnabled:NO];

Which does not work. Disabling the right button item works as a charm.

Surprisingly enough I could not find a similar question on SO. The closest one was about hiding the button (which works btw) but this is not so elegant (or adding a label to cover the button and prevent touches which keeps the same color of the back button –> also not so elegant:/).

I should mention that the view controller is a table view controller which is pushed by another navigation controller. (i.e. the back button is added automatically and not via IB or programmaticaly)

Any ideas ?

Best Answer

You can hide using

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