0
有人能幫我解答一下我的問題嗎?將圖片設置爲按鈕
當我調用myFunction時,我想要設置爲按鈕的圖像在2秒後同時出現,而不是一個接一個地延遲0.5秒。
更多信息:
- generatedNumbers是陣列的NSNumber的四個元素(4,1,3,2)
- 按鈕中的UIView經由IB設定和被標記(1,2,3 4)
-(IBAction) myFunction:(id) sender {
int i, value;
for (i = 0; i<[generatedNumbers count]; i++) {
value = [[generatedNumbers objectAtIndex:i] intValue];
UIButton *button = (UIButton *)[self.view viewWithTag:i+1];
UIImage *img = [UIImage imageNamed:[NSString stringWithFormat:@"%d.png",value]];
[button setImage:img forState:UIControlStateNormal];
[img release];
usleep(500000);
}
}
您能否向我解釋如何將NSTimer集成到我的功能? – Ivan 2010-05-04 20:48:45
http://developer.apple.com/iphone/library/documentation/Cocoa/Reference/Foundation/Classes/NSTimer_Class/Reference/NSTimer.html – 2010-05-05 02:01:13