我正在尝试按顺序更改25个按钮的图像,并且更改之间有延迟时间,但它不起作用。
代码是:
do {
if (Anterior > -1) {
[[BtnArray objectAtIndex(Anterior)] setImage:Nil];
}
[[BtnArray objectAtIndex:(Gira[J])]
setImage:[NSImage imageNamed:@"Encen.png"]];
Anterior = Gira[J];
Delay(Espera,&junk);
++J;
} while (J<25);
答案 0 :(得分:0)
尚未测试,但您可以尝试这样的事情:
float delay = .2;
for (UIButton *btn in btnArray) {
[btn performSelector:@selector(setImage:) withObject:[UIImage imageNamed:@"Encen.png"] afterDelay:delay];
delay += .2;
}
或者代替呼叫btn有自己的功能
float delay = .2;
for (UIButton *btn in btnArray) {
[self performSelector:@selector(changeImageForButton:) withObject:btn afterDelay:delay];
delay += .2;
}
然后在该函数中执行:
[btn setImage:[UIImage imageNamed:@"Encen.png"] forState:UIControlStateNormal];