0

如何更改 NSMutable 数组中按钮(在索引处)的属性?

这是我的代码:

                [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

任何人都可以帮忙吗?

4

1 回答 1

0

更正

UIButton方法setBackgroundImage:forState:接受UIImage作为参数而不是NSString。如下更改该行。

[newbutton setBackgroundImage:[UIImage imageNamed:@"buttonmem3"] forState:UIControlStateNormal];

假设您在应用程序包中添加了“buttonmem3.png”。

于 2013-09-25T12:39:47.107 回答