0
我的应用程序有50个按钮。我想以编程方式将图像添加到按钮到所有按钮。如何将图像添加到多个按钮
我声明通过出口按钮作为
@property (strong, nonatomic) IBOutlet UIButton *radiobtn1;
@property (strong, nonatomic) IBOutlet UIButton *radiobtn2;
@property (strong, nonatomic) IBOutlet UIButton *radiobtn3.
.
.
@property (strong, nonatomic) IBOutlet UIButton *radiobtn50;
这是我的阵列
NSMutableArray *allButtons;
allButtons = [[NSMutableArray alloc] init];
allButtons = [NSMutableArray arrayWithObjects:@"radiobtn1", .....,@"radiobtn50",nil];
这是我的逻辑
for (i = 0; i <= 50; i++)
{
[self.allbuttons[i] setImage:[UIImage imageNamed:@"radioButtonDisabled.png"] forState:UIControlStateSelected];
}
but application is crashing with exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString setImage:forState:]: unrecognized selector sent to instance 0x16d4c'
将“<=”更改为“<”, – 2014-10-11 07:37:40