【发布时间】:2017-07-07 15:18:35
【问题描述】:
我试图通过代码隐藏一个按钮,但每次我试图隐藏它时程序都会崩溃。
我得到的错误:
'NSInvalidArgumentException', reason: '-[UIBarButtonItem setHidden:]: unrecognized selector sent to instance 0x14ef8f30'
.h 文件代码:
@property (strong) UIButton *takeAll;
.m 代码:
@synthesize takeAll;
// function
[self.takeAll setHidden:YES];
【问题讨论】:
-
添加
takeAll按钮分配代码 -
takeAll 是 UIBarButtonItem,您可能希望将插座与此 buttonItem 内的按钮相关联。
-
由于某种原因,当我将其声明为 UIBarButtonItem 时无法隐藏它,我该如何解决?
-
为什么有
@synthesize行?很多年都不需要了。您应该找到最新的 Objective-C 教程。 -
iOS 新手,正在处理一个较旧的项目,所以我一直在遵循格式。感谢您的建议
标签: ios objective-c uibutton