【发布时间】:2010-11-11 00:01:51
【问题描述】:
想将我的 NSTimer 代码更改为使用 applicationSignificantTimeChange
这就是我现在拥有的。
基本上我想更改计时器,而不是每 5 秒更改一次,例如我希望这些 textLabels 在每晚 12 点更改,有人帮帮我吗?
//h file
NSTimer *timer;
IBOutlet UILabel *textLabel;
//m file
- (void)onTimer {
static int i = 0;
if ( i == 0 ) {
textLabel.text = @"iphone app";
}
else if ( i == 1 ) {
textLabel.text = @" Great App!";
}
else if ( i == 2 ) {
textLabel.text = @" WOW!";
}
else {
textLabel.text = @" great application again!!";
i = -1;
}
i++;
}
timer =[NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
【问题讨论】: