如何更改NSMutable Array中按钮(在索引处)的属性?
这是我的代码:
[btnRange addObject:btn12Out];
[btnRange addObject:btn13Out];
[btnRange addObject:btn14Out];
[btnRange addObject:btn17Out];
[btnRange addObject:btn18Out];
[btnRange addObject:btn19Out];
//start ordering
for (NSInteger i=0; i <= 5; i++) {
nxt = btnRange[arc4random_uniform([btnRange count])];
btnOrder[i] = nxt;
[btnRange removeObject:nxt];
}
//skipping down
if ([status isEqualToString:@"Computer"]) {
switch (level) {
case 1:
//here's where I want to edit the properties
//of a buttonn in the array (at a certain index)
nxt = btnOrder[current];
UIButton *newbutton = nxt;
[newbutton setBackgroundImage:@"buttonmem3" forstate:UIControlStateNormal];
//Fin
但是xcode喜欢说“newbutton”没有@interfae
有人可以帮忙吗?
答案 0 :(得分:0)
<强>校正强>:
UIButton
方法setBackgroundImage:forState:
接受UIImage
作为参数而非NSString
。更改以下行。
[newbutton setBackgroundImage:[UIImage imageNamed:@"buttonmem3"] forState:UIControlStateNormal];
假设您的应用包中添加了“buttonmem3.png”。