How to disable UIBarButtonItem?

Solution 1:

You can disable the left navigation button from inside an UIViewController like this, without using any IBOutlet:

self.navigationItem.leftBarButtonItem.enabled = NO;

To disable the right navigation button:

self.navigationItem.rightBarButtonItem.enabled = NO;

Swift3

self.navigationItem.rightBarButtonItem?.isEnabled = false

Solution 2:

If your toolbar has an IBOutlet (and you've checked to make sure it's non-nil), try:

[ [ [ myToolBar items ] objectAtIndex: myBarButtonItemIndex ] setEnabled:(NO) ];