我在viewDidLoad中定义了此按钮:
UIBarButtonItem *lotBtn = [[UIBarButtonItem alloc] initWithTitle:@"Lot" style:UIBarButtonItemStylePlain target:self action:@selector(insertNewObject:)];
我在这条线上出现错误:
[lotBtn setTitle:unitPickerSelectionString forState:UIControlStateNormal];
使用未声明的标识符“ lotBtn”
我需要在.h文件中定义lotBtn吗?
@property (strong, nonatomic) IBOutlet UIBarButtonItem *lotBtn;
括号内定义的对象{ }
将无法在括号外访问(除非传递)。
您的媒体资源实现将正常工作。您还可以从班级外部访问该属性。如果只希望在当前类中使用它(我想您可能会这么想),则可以这样定义它:
@implementation YourViewController {
UIBarButtonItem *lotBtn
}
- (void)viewDidLoad {
lotBtn = [[UIBarButtonItem alloc] initWithTitle:@"Lot" style:UIBarButtonItemStylePlain target:self action:@selector(insertNewObject:)];
}
然后,您UIBarButtonItem
将在整个期间都可以使用ViewController
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句