如何在iOS中禁用导航栏按钮项 [英] how to disable a navigation bar button item in iOS
问题描述
我创建了一个导航控制器。在第二个视图(推送)中,我有一些webservice调用并放置覆盖视图和设置
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).
我尝试过使用 self .navigationItem.backBarButtonItem.enabled = NO
。但我仍然能够点击按钮并可以导航到第一个屏幕。如何禁用这两个按钮?
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 ?
推荐答案
试试这个
推荐
self.navigationItem.leftBarButtonItem.enabled = NO;
self.navigationItem.rightBarButtonItem.enabled = NO;
或简单地禁用
在Edge上case
on Edge case
self.view.window.userInteractionEnabled = NO;
更新:
最近Apple不允许退回按钮启用/禁用。而不是我们可以隐藏它。
Update: Recently Apple doesn't allow the back button to enable / disable. Instead of that we can hide it.
self.navigationItem.hidesBackButton = YES;
这篇关于如何在iOS中禁用导航栏按钮项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!