我有一个自定义按钮,我想分配一个字符串,然后将该按钮作为@selector 中的参数传递。出于这个原因,在头文件 CustomButton 中,我放置了一个属性“名称”。但是,当我将字符串分配给按钮时,出现此错误。
'NSInvalidArgumentException', reason: '-[UIButton setName:]: unrecognized selector sent
to instance 0x8484560'
这是什么意思?
CustomButton.h 中的代码:
@interface CustomButton : UIButton
@property (nonatomic, strong)NSString * name;
@end
CustomButton.m 中的代码:
@synthesize name;
在 MapViewController.m
CustomButton *rightButton = [CustomButton buttonWithType:UIButtonTypeInfoLight];
NSLog(@"The button is %@", rightButton);
/*The button is <UIButton: 0x8484560; frame = (0 0; 18 19); opaque = NO; layer =
<CALayer: 0x8484670>>*/
rightButton.name = self.nameTable; //the error is here