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 ?
ios ios7 uinavigationbar
add a comment |
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 ?
ios ios7 uinavigationbar
add a comment |
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 ?
ios ios7 uinavigationbar
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 ?
ios ios7 uinavigationbar
ios ios7 uinavigationbar
edited Aug 18 '14 at 18:24
rmaddy
238k27310376
238k27310376
asked Aug 18 '14 at 11:18
SravanSravan
5123721
5123721
add a comment |
add a comment |
12 Answers
12
active
oldest
votes
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;
2
Both didn't work. I am still able to tap the button and navigate to the first view controller.
– Sravan
Aug 18 '14 at 13:44
@Sravan Are you building the buttons in storyboard or dynamically? Building dynamically may have impact I suppose. Try placing this logic after you added the buttons to the navigationbar
– Jay Mayu
Mar 17 '15 at 6:03
add a comment |
You can do the following if you are running on Swift
self.navigationItem.rightBarButtonItem?.enabled = true
This snippet will disable the button.
add a comment |
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;
2
This didnt worked. I am still able to tap the button and navigate to frist view controller.
– Sravan
Aug 18 '14 at 13:44
@Sravan I just edited my answer, does it work better?
– jbouaziz
Aug 18 '14 at 13:58
disabling interaction is fine and you can disable a button at a time, navigation bar buttons or the entire window. However, be sure you can always enable them. You might want to consider wrapping the 'disable' logic in a timer. For example, imagine you started a download but it did not finish correctly, is your app going to hang? Do you want to trigger a retry? Enable all?
– goggelj
Jul 12 '16 at 12:13
add a comment |
Latest Swift: To hide the back button, you MUST use:
self.navigationItem.setHidesBackButton(true, animated: false)
Note: This can trigger a bug in the navigation bar that can cause an artifact to appear in place of a hidden back button when transitioning to a view that doesn't have a back button (or has a leftButton in its place). The artifact that appears is either ellipses "..." or the title of the previous viewController on the stack. I believe this bug to be related to the bug documented in apple's own sample code project "CustomizingUINavigationBar", CustomBackButtonViewController.m
add a comment |
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationItem.leftBarButtonItem=nil;
self.navigationItem.hidesBackButton=YES;
}
add a comment |
I solved this by just adding a property to my viewcontroller:
@property (nonatomic, strong) IBOutlet UIBarButtonItem * RightButton;
I then connected it to the button on the storyboard.
You can then at will set its properties like:
self.RightButton.enabled=true;
add a comment |
Updated for Swift 3:
If you want to disable a navigation bar button item OR you want to disable hole UINavigationBar i.e. all item present on navigation bar, use below lines of code;
// if you want disable
self.navigationController?.navigationBar.isUserInteractionEnabled = false
// if you want enable again
self.navigationController?.navigationBar.isUserInteractionEnabled = true
Enjoy...!
add a comment |
For version iOS 10.3, swift 3:
self.navigationItem.rightBarButtonItem?.isEnabled = false.
add a comment |
One line solution
self.navigationController?.view.isUserInteractionEnabled = false
add a comment |
Try this code:
UIApplication.sharedApplication().beginIgnoringInteractionEvents()
This will stop user to interaction with app and after service call, write this code again:
UIApplication.sharedApplication().endIgnoringInteractionEvents()
Sure this will help.
add a comment |
var menuBtn = new UIButton(UIButtonType.Custom);
menuBtn.Frame = new CGRect(x: 0.0, y: 0.0, width: 20, height: 20);
menuBtn.SetImage(new UIImage("filter"), UIControlState.Normal);
menuBtn.Alpha = 0.05f; //to set the Alpha
menuBtn.Enabled = false;
tested on Mvvmcross Xamarin.iOS only
Add some description and format answer
– Billa
Aug 23 '18 at 11:15
add a comment |
Navigation bar button items must be toggled by referring to them via the navigationItem property.
For example:
func setupNav() {
let saveButton = UIBarButtonItem.init(barButtonSystemItem: .save, target: self, action: #selector(onSavePressed))
navigationItem.rightBarButtonItem = saveButton
saveButton.isEnabled = false
}
func validateSave() {
saveButton.isEnabled = isConditionMet // WON'T work
navigationItem.rightBarButtonItem.isEnabled = isConditionMet // WORKS!
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f25362050%2fhow-to-disable-a-navigation-bar-button-item-in-ios%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
12 Answers
12
active
oldest
votes
12 Answers
12
active
oldest
votes
active
oldest
votes
active
oldest
votes
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;
2
Both didn't work. I am still able to tap the button and navigate to the first view controller.
– Sravan
Aug 18 '14 at 13:44
@Sravan Are you building the buttons in storyboard or dynamically? Building dynamically may have impact I suppose. Try placing this logic after you added the buttons to the navigationbar
– Jay Mayu
Mar 17 '15 at 6:03
add a comment |
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;
2
Both didn't work. I am still able to tap the button and navigate to the first view controller.
– Sravan
Aug 18 '14 at 13:44
@Sravan Are you building the buttons in storyboard or dynamically? Building dynamically may have impact I suppose. Try placing this logic after you added the buttons to the navigationbar
– Jay Mayu
Mar 17 '15 at 6:03
add a comment |
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;
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;
edited Dec 3 '14 at 9:01
answered Aug 18 '14 at 11:33
Vijay-Apple-Dev.blogspot.comVijay-Apple-Dev.blogspot.com
24.4k76173
24.4k76173
2
Both didn't work. I am still able to tap the button and navigate to the first view controller.
– Sravan
Aug 18 '14 at 13:44
@Sravan Are you building the buttons in storyboard or dynamically? Building dynamically may have impact I suppose. Try placing this logic after you added the buttons to the navigationbar
– Jay Mayu
Mar 17 '15 at 6:03
add a comment |
2
Both didn't work. I am still able to tap the button and navigate to the first view controller.
– Sravan
Aug 18 '14 at 13:44
@Sravan Are you building the buttons in storyboard or dynamically? Building dynamically may have impact I suppose. Try placing this logic after you added the buttons to the navigationbar
– Jay Mayu
Mar 17 '15 at 6:03
2
2
Both didn't work. I am still able to tap the button and navigate to the first view controller.
– Sravan
Aug 18 '14 at 13:44
Both didn't work. I am still able to tap the button and navigate to the first view controller.
– Sravan
Aug 18 '14 at 13:44
@Sravan Are you building the buttons in storyboard or dynamically? Building dynamically may have impact I suppose. Try placing this logic after you added the buttons to the navigationbar
– Jay Mayu
Mar 17 '15 at 6:03
@Sravan Are you building the buttons in storyboard or dynamically? Building dynamically may have impact I suppose. Try placing this logic after you added the buttons to the navigationbar
– Jay Mayu
Mar 17 '15 at 6:03
add a comment |
You can do the following if you are running on Swift
self.navigationItem.rightBarButtonItem?.enabled = true
This snippet will disable the button.
add a comment |
You can do the following if you are running on Swift
self.navigationItem.rightBarButtonItem?.enabled = true
This snippet will disable the button.
add a comment |
You can do the following if you are running on Swift
self.navigationItem.rightBarButtonItem?.enabled = true
This snippet will disable the button.
You can do the following if you are running on Swift
self.navigationItem.rightBarButtonItem?.enabled = true
This snippet will disable the button.
answered Jul 8 '15 at 9:30
Jay MayuJay Mayu
10.7k28100135
10.7k28100135
add a comment |
add a comment |
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;
2
This didnt worked. I am still able to tap the button and navigate to frist view controller.
– Sravan
Aug 18 '14 at 13:44
@Sravan I just edited my answer, does it work better?
– jbouaziz
Aug 18 '14 at 13:58
disabling interaction is fine and you can disable a button at a time, navigation bar buttons or the entire window. However, be sure you can always enable them. You might want to consider wrapping the 'disable' logic in a timer. For example, imagine you started a download but it did not finish correctly, is your app going to hang? Do you want to trigger a retry? Enable all?
– goggelj
Jul 12 '16 at 12:13
add a comment |
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;
2
This didnt worked. I am still able to tap the button and navigate to frist view controller.
– Sravan
Aug 18 '14 at 13:44
@Sravan I just edited my answer, does it work better?
– jbouaziz
Aug 18 '14 at 13:58
disabling interaction is fine and you can disable a button at a time, navigation bar buttons or the entire window. However, be sure you can always enable them. You might want to consider wrapping the 'disable' logic in a timer. For example, imagine you started a download but it did not finish correctly, is your app going to hang? Do you want to trigger a retry? Enable all?
– goggelj
Jul 12 '16 at 12:13
add a comment |
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;
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;
edited Aug 18 '14 at 13:58
answered Aug 18 '14 at 11:44
jbouazizjbouaziz
1,39011022
1,39011022
2
This didnt worked. I am still able to tap the button and navigate to frist view controller.
– Sravan
Aug 18 '14 at 13:44
@Sravan I just edited my answer, does it work better?
– jbouaziz
Aug 18 '14 at 13:58
disabling interaction is fine and you can disable a button at a time, navigation bar buttons or the entire window. However, be sure you can always enable them. You might want to consider wrapping the 'disable' logic in a timer. For example, imagine you started a download but it did not finish correctly, is your app going to hang? Do you want to trigger a retry? Enable all?
– goggelj
Jul 12 '16 at 12:13
add a comment |
2
This didnt worked. I am still able to tap the button and navigate to frist view controller.
– Sravan
Aug 18 '14 at 13:44
@Sravan I just edited my answer, does it work better?
– jbouaziz
Aug 18 '14 at 13:58
disabling interaction is fine and you can disable a button at a time, navigation bar buttons or the entire window. However, be sure you can always enable them. You might want to consider wrapping the 'disable' logic in a timer. For example, imagine you started a download but it did not finish correctly, is your app going to hang? Do you want to trigger a retry? Enable all?
– goggelj
Jul 12 '16 at 12:13
2
2
This didnt worked. I am still able to tap the button and navigate to frist view controller.
– Sravan
Aug 18 '14 at 13:44
This didnt worked. I am still able to tap the button and navigate to frist view controller.
– Sravan
Aug 18 '14 at 13:44
@Sravan I just edited my answer, does it work better?
– jbouaziz
Aug 18 '14 at 13:58
@Sravan I just edited my answer, does it work better?
– jbouaziz
Aug 18 '14 at 13:58
disabling interaction is fine and you can disable a button at a time, navigation bar buttons or the entire window. However, be sure you can always enable them. You might want to consider wrapping the 'disable' logic in a timer. For example, imagine you started a download but it did not finish correctly, is your app going to hang? Do you want to trigger a retry? Enable all?
– goggelj
Jul 12 '16 at 12:13
disabling interaction is fine and you can disable a button at a time, navigation bar buttons or the entire window. However, be sure you can always enable them. You might want to consider wrapping the 'disable' logic in a timer. For example, imagine you started a download but it did not finish correctly, is your app going to hang? Do you want to trigger a retry? Enable all?
– goggelj
Jul 12 '16 at 12:13
add a comment |
Latest Swift: To hide the back button, you MUST use:
self.navigationItem.setHidesBackButton(true, animated: false)
Note: This can trigger a bug in the navigation bar that can cause an artifact to appear in place of a hidden back button when transitioning to a view that doesn't have a back button (or has a leftButton in its place). The artifact that appears is either ellipses "..." or the title of the previous viewController on the stack. I believe this bug to be related to the bug documented in apple's own sample code project "CustomizingUINavigationBar", CustomBackButtonViewController.m
add a comment |
Latest Swift: To hide the back button, you MUST use:
self.navigationItem.setHidesBackButton(true, animated: false)
Note: This can trigger a bug in the navigation bar that can cause an artifact to appear in place of a hidden back button when transitioning to a view that doesn't have a back button (or has a leftButton in its place). The artifact that appears is either ellipses "..." or the title of the previous viewController on the stack. I believe this bug to be related to the bug documented in apple's own sample code project "CustomizingUINavigationBar", CustomBackButtonViewController.m
add a comment |
Latest Swift: To hide the back button, you MUST use:
self.navigationItem.setHidesBackButton(true, animated: false)
Note: This can trigger a bug in the navigation bar that can cause an artifact to appear in place of a hidden back button when transitioning to a view that doesn't have a back button (or has a leftButton in its place). The artifact that appears is either ellipses "..." or the title of the previous viewController on the stack. I believe this bug to be related to the bug documented in apple's own sample code project "CustomizingUINavigationBar", CustomBackButtonViewController.m
Latest Swift: To hide the back button, you MUST use:
self.navigationItem.setHidesBackButton(true, animated: false)
Note: This can trigger a bug in the navigation bar that can cause an artifact to appear in place of a hidden back button when transitioning to a view that doesn't have a back button (or has a leftButton in its place). The artifact that appears is either ellipses "..." or the title of the previous viewController on the stack. I believe this bug to be related to the bug documented in apple's own sample code project "CustomizingUINavigationBar", CustomBackButtonViewController.m
edited Sep 10 '15 at 14:19
answered Sep 10 '15 at 14:08
ObjectiveTCObjectiveTC
1,5932218
1,5932218
add a comment |
add a comment |
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationItem.leftBarButtonItem=nil;
self.navigationItem.hidesBackButton=YES;
}
add a comment |
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationItem.leftBarButtonItem=nil;
self.navigationItem.hidesBackButton=YES;
}
add a comment |
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationItem.leftBarButtonItem=nil;
self.navigationItem.hidesBackButton=YES;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationItem.leftBarButtonItem=nil;
self.navigationItem.hidesBackButton=YES;
}
answered Oct 15 '15 at 5:41
user4919266
add a comment |
add a comment |
I solved this by just adding a property to my viewcontroller:
@property (nonatomic, strong) IBOutlet UIBarButtonItem * RightButton;
I then connected it to the button on the storyboard.
You can then at will set its properties like:
self.RightButton.enabled=true;
add a comment |
I solved this by just adding a property to my viewcontroller:
@property (nonatomic, strong) IBOutlet UIBarButtonItem * RightButton;
I then connected it to the button on the storyboard.
You can then at will set its properties like:
self.RightButton.enabled=true;
add a comment |
I solved this by just adding a property to my viewcontroller:
@property (nonatomic, strong) IBOutlet UIBarButtonItem * RightButton;
I then connected it to the button on the storyboard.
You can then at will set its properties like:
self.RightButton.enabled=true;
I solved this by just adding a property to my viewcontroller:
@property (nonatomic, strong) IBOutlet UIBarButtonItem * RightButton;
I then connected it to the button on the storyboard.
You can then at will set its properties like:
self.RightButton.enabled=true;
answered Feb 13 '17 at 11:15
SjakelienSjakelien
87521130
87521130
add a comment |
add a comment |
Updated for Swift 3:
If you want to disable a navigation bar button item OR you want to disable hole UINavigationBar i.e. all item present on navigation bar, use below lines of code;
// if you want disable
self.navigationController?.navigationBar.isUserInteractionEnabled = false
// if you want enable again
self.navigationController?.navigationBar.isUserInteractionEnabled = true
Enjoy...!
add a comment |
Updated for Swift 3:
If you want to disable a navigation bar button item OR you want to disable hole UINavigationBar i.e. all item present on navigation bar, use below lines of code;
// if you want disable
self.navigationController?.navigationBar.isUserInteractionEnabled = false
// if you want enable again
self.navigationController?.navigationBar.isUserInteractionEnabled = true
Enjoy...!
add a comment |
Updated for Swift 3:
If you want to disable a navigation bar button item OR you want to disable hole UINavigationBar i.e. all item present on navigation bar, use below lines of code;
// if you want disable
self.navigationController?.navigationBar.isUserInteractionEnabled = false
// if you want enable again
self.navigationController?.navigationBar.isUserInteractionEnabled = true
Enjoy...!
Updated for Swift 3:
If you want to disable a navigation bar button item OR you want to disable hole UINavigationBar i.e. all item present on navigation bar, use below lines of code;
// if you want disable
self.navigationController?.navigationBar.isUserInteractionEnabled = false
// if you want enable again
self.navigationController?.navigationBar.isUserInteractionEnabled = true
Enjoy...!
answered Dec 8 '17 at 4:38
Kiran jadhavKiran jadhav
1,5451417
1,5451417
add a comment |
add a comment |
For version iOS 10.3, swift 3:
self.navigationItem.rightBarButtonItem?.isEnabled = false.
add a comment |
For version iOS 10.3, swift 3:
self.navigationItem.rightBarButtonItem?.isEnabled = false.
add a comment |
For version iOS 10.3, swift 3:
self.navigationItem.rightBarButtonItem?.isEnabled = false.
For version iOS 10.3, swift 3:
self.navigationItem.rightBarButtonItem?.isEnabled = false.
edited Nov 23 '18 at 7:46
kit
1,1063716
1,1063716
answered Mar 7 '18 at 9:48
Sagar DSagar D
1056
1056
add a comment |
add a comment |
One line solution
self.navigationController?.view.isUserInteractionEnabled = false
add a comment |
One line solution
self.navigationController?.view.isUserInteractionEnabled = false
add a comment |
One line solution
self.navigationController?.view.isUserInteractionEnabled = false
One line solution
self.navigationController?.view.isUserInteractionEnabled = false
answered Oct 11 '17 at 12:05
Ghulam RasoolGhulam Rasool
2,12911326
2,12911326
add a comment |
add a comment |
Try this code:
UIApplication.sharedApplication().beginIgnoringInteractionEvents()
This will stop user to interaction with app and after service call, write this code again:
UIApplication.sharedApplication().endIgnoringInteractionEvents()
Sure this will help.
add a comment |
Try this code:
UIApplication.sharedApplication().beginIgnoringInteractionEvents()
This will stop user to interaction with app and after service call, write this code again:
UIApplication.sharedApplication().endIgnoringInteractionEvents()
Sure this will help.
add a comment |
Try this code:
UIApplication.sharedApplication().beginIgnoringInteractionEvents()
This will stop user to interaction with app and after service call, write this code again:
UIApplication.sharedApplication().endIgnoringInteractionEvents()
Sure this will help.
Try this code:
UIApplication.sharedApplication().beginIgnoringInteractionEvents()
This will stop user to interaction with app and after service call, write this code again:
UIApplication.sharedApplication().endIgnoringInteractionEvents()
Sure this will help.
edited Nov 23 '18 at 10:59
kit
1,1063716
1,1063716
answered Jun 29 '16 at 9:15
Muhammad FasiMuhammad Fasi
577
577
add a comment |
add a comment |
var menuBtn = new UIButton(UIButtonType.Custom);
menuBtn.Frame = new CGRect(x: 0.0, y: 0.0, width: 20, height: 20);
menuBtn.SetImage(new UIImage("filter"), UIControlState.Normal);
menuBtn.Alpha = 0.05f; //to set the Alpha
menuBtn.Enabled = false;
tested on Mvvmcross Xamarin.iOS only
Add some description and format answer
– Billa
Aug 23 '18 at 11:15
add a comment |
var menuBtn = new UIButton(UIButtonType.Custom);
menuBtn.Frame = new CGRect(x: 0.0, y: 0.0, width: 20, height: 20);
menuBtn.SetImage(new UIImage("filter"), UIControlState.Normal);
menuBtn.Alpha = 0.05f; //to set the Alpha
menuBtn.Enabled = false;
tested on Mvvmcross Xamarin.iOS only
Add some description and format answer
– Billa
Aug 23 '18 at 11:15
add a comment |
var menuBtn = new UIButton(UIButtonType.Custom);
menuBtn.Frame = new CGRect(x: 0.0, y: 0.0, width: 20, height: 20);
menuBtn.SetImage(new UIImage("filter"), UIControlState.Normal);
menuBtn.Alpha = 0.05f; //to set the Alpha
menuBtn.Enabled = false;
tested on Mvvmcross Xamarin.iOS only
var menuBtn = new UIButton(UIButtonType.Custom);
menuBtn.Frame = new CGRect(x: 0.0, y: 0.0, width: 20, height: 20);
menuBtn.SetImage(new UIImage("filter"), UIControlState.Normal);
menuBtn.Alpha = 0.05f; //to set the Alpha
menuBtn.Enabled = false;
tested on Mvvmcross Xamarin.iOS only
edited Nov 23 '18 at 11:12
ttarchala
2,0791929
2,0791929
answered Aug 23 '18 at 10:57
KomiconKomicon
105
105
Add some description and format answer
– Billa
Aug 23 '18 at 11:15
add a comment |
Add some description and format answer
– Billa
Aug 23 '18 at 11:15
Add some description and format answer
– Billa
Aug 23 '18 at 11:15
Add some description and format answer
– Billa
Aug 23 '18 at 11:15
add a comment |
Navigation bar button items must be toggled by referring to them via the navigationItem property.
For example:
func setupNav() {
let saveButton = UIBarButtonItem.init(barButtonSystemItem: .save, target: self, action: #selector(onSavePressed))
navigationItem.rightBarButtonItem = saveButton
saveButton.isEnabled = false
}
func validateSave() {
saveButton.isEnabled = isConditionMet // WON'T work
navigationItem.rightBarButtonItem.isEnabled = isConditionMet // WORKS!
}
add a comment |
Navigation bar button items must be toggled by referring to them via the navigationItem property.
For example:
func setupNav() {
let saveButton = UIBarButtonItem.init(barButtonSystemItem: .save, target: self, action: #selector(onSavePressed))
navigationItem.rightBarButtonItem = saveButton
saveButton.isEnabled = false
}
func validateSave() {
saveButton.isEnabled = isConditionMet // WON'T work
navigationItem.rightBarButtonItem.isEnabled = isConditionMet // WORKS!
}
add a comment |
Navigation bar button items must be toggled by referring to them via the navigationItem property.
For example:
func setupNav() {
let saveButton = UIBarButtonItem.init(barButtonSystemItem: .save, target: self, action: #selector(onSavePressed))
navigationItem.rightBarButtonItem = saveButton
saveButton.isEnabled = false
}
func validateSave() {
saveButton.isEnabled = isConditionMet // WON'T work
navigationItem.rightBarButtonItem.isEnabled = isConditionMet // WORKS!
}
Navigation bar button items must be toggled by referring to them via the navigationItem property.
For example:
func setupNav() {
let saveButton = UIBarButtonItem.init(barButtonSystemItem: .save, target: self, action: #selector(onSavePressed))
navigationItem.rightBarButtonItem = saveButton
saveButton.isEnabled = false
}
func validateSave() {
saveButton.isEnabled = isConditionMet // WON'T work
navigationItem.rightBarButtonItem.isEnabled = isConditionMet // WORKS!
}
answered Dec 18 '18 at 5:49
DiviyoDiviyo
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f25362050%2fhow-to-disable-a-navigation-bar-button-item-in-ios%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown