xcode 如何禁用导航的右侧栏按钮

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2653103/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 19:17:10  来源:igfitidea点击:

How to disable the right bar button of navigation

iphoneobjective-cxcode

提问by madhavi

self.navigationItem.rightBarButtonItem.enabled = FALSE;
[activityIndicator startAnimating];
//[myview sendSubviewToBack:self.view];
//self.view.hidden= TRUE;
myview.hidden= FALSE;
activityIndicator.hidden= FALSE;
dt = [[DateTime alloc] init];

This is my method in this when user click on leftbar button of navigation this method fires here i want to disable the button but its not getting disable and i checked my code i am not enabling it anywhere.......Please help me

这是我的方法,当用户单击导航的左栏按钮时,此方法会在此处触发

采纳答案by Steve Neal

If properties aren't initialised properly in Objective-C you won't see any errors, the statement just won't get executed..

如果在 Objective-C 中没有正确初始化属性,您将不会看到任何错误,该语句将不会被执行..

My first guess would be that you're calling a method on a nil reference.

我的第一个猜测是你在一个 nil 引用上调用一个方法。

Use the debugger to see whether the rightBarButtonItem has been set up properly.

使用调试器查看rightBarButtonItem 是否设置正确。

回答by beryllium

Just

只是

self.navigationItem.rightBarButtonItem.enabled = NO;