Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to disable a navigation bar button item in iOS

I have created a navigation controller. In the second view (which is pushed), I have some webservice call and placing a overlay view and setting

self.view.userInteractionEnabled = NO ;

Once web service call is complete, then I am reverting to

self.view.userInteractionEnabled = YES ;

When I do this, every other buttons except the buttons on the navigation bar are disabled. How to disable those two navigation bar button items ? (a button similar to back button, which pops to first view controller and another button which gives info about help).

I have tried using self.navigationItem.backBarButtonItem.enabled = NO. But still I am able to tap on the button and can navigate to first screen. How can I disable these two buttons ?

like image 708
Sravan Avatar asked Aug 18 '14 11:08

Sravan


People also ask

How do I disable the navigation bar button?

Navigate to Android > Restrictions > Advanced and click on Configure. Under Display Settings, check the option Hide Navigation Bar. Hide Navigation Bar – You can hide/display the navigation bar using this option.

How do I disable the Back button on my Iphone?

Yes, the back button can be disabled. Please navigate to Advanced Website Kiosk Settings–>Navigation–>Disable back button. Kindly enable this restriction to disallow the usage of the back button on the iOS device.

Can you change Iphone navigation bar?

A user changes the navigation bar's style, or UIBarStyle , by tapping the “Style” button to the left of the main page. This button opens an action sheet where users can change the background's appearance to default, black-opaque, or black- translucent.


Video Answer


2 Answers

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; 
like image 74
Vijay-Apple-Dev.blogspot.com Avatar answered Sep 21 '22 17:09

Vijay-Apple-Dev.blogspot.com


You can do the following if you are running on Swift

self.navigationItem.rightBarButtonItem?.enabled = true 

This snippet will disable the button.

like image 41
Jay Mayu Avatar answered Sep 19 '22 17:09

Jay Mayu