我有一个 NSMutableArray,我用这样的 UIImageViews 填充:
NSMutableArray *digitArray;
spaces = [[NSMutableArray alloc] initWithCapacity:16];
[spaces addObject:space1];
[spaces addObject:space2];
[spaces addObject:space3];
[spaces addObject:space4];
[spaces addObject:space5];
[spaces addObject:space6];
[spaces addObject:space7];
[spaces addObject:space8];
[spaces addObject:space9];
[spaces addObject:space10];
[spaces addObject:space11];
[spaces addObject:space12];
[spaces addObject:space13];
[spaces addObject:space14];
[spaces addObject:space15];
[spaces addObject:space16];
然后我为每个 UIImageViews 分配一个图像,如下所示:
[(UIImageView *)spaces[0] setImage:one];
[(UIImageView *)spaces[1] setImage:two];
[(UIImageView *)spaces[2] setImage:three];
[(UIImageView *)spaces[3] setImage:four];
[(UIImageView *)spaces[4] setImage:five];
[(UIImageView *)spaces[5] setImage:six];
[(UIImageView *)spaces[6] setImage:seven];
[(UIImageView *)spaces[7] setImage:eight];
[(UIImageView *)spaces[8] setImage:nine];
[(UIImageView *)spaces[9] setImage:ten];
[(UIImageView *)spaces[10] setImage:eleven];
[(UIImageView *)spaces[11] setImage:twelve];
[(UIImageView *)spaces[12] setImage:thirteen];
[(UIImageView *)spaces[13] setImage:fourteen];
[(UIImageView *)spaces[14] setImage:fifteen];
[(UIImageView *)spaces[15] setImage:sixteen];
因此,将此作为我的默认组合,然后我希望能够随机更改分配给哪个 UIImageVIew 的图像。任何人都可以建议这样做的方法吗?
提前致谢!
乔治