how to disable a navigation bar button item in iOS how to disable a navigation bar button item in iOS ios ios

how to disable a navigation bar button item in iOS


Try this

Recommended

self.navigationItem.leftBarButtonItem.enabled = NO;self.navigationItem.rightBarButtonItem.enabled = NO;

Or Simply Disable by

on Edge case

self.view.window.userInteractionEnabled = NO;

Update:Recently Apple doesn't allow the back button to enable / disable. Instead of that we can hide it.

self.navigationItem.hidesBackButton = YES;


You can do the following if you are running on Swift

self.navigationItem.rightBarButtonItem?.enabled = true

This snippet will disable the button.


Just disable your UINavigationController view and navigation bar interaction:

self.navigationController.navigationBar.userInteractionEnabled = NO;self.navigationController.view.userInteractionEnabled = NO;

And enable it when you need it back:

self.navigationController.navigationBar.userInteractionEnabled = YES;self.navigationController.view.userInteractionEnabled = YES;