Vote count:
0
In my app, I want to use a NSTimer update my UIButton instance, but my button's title didn't change as the time elapse. My code is here:
-(void)fireTimer{
self.leftTime = 30;
self.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerAction) userInfo:nil repeats:YES];
[self.timer fire];
}
- (void)timerAction
{
self.leftTime--;
NSLog(@"%d current runloop and mode is %@", self.leftTime, [NSRunLoop currentRunLoop].currentMode);
[self.customBtn setTitle:[NSString stringWithFormat:@"leftTime:%d", self.leftTime] forState:UIControlStateNormal];
if(self.leftTime == 0)
{
[self.timer invalidate];
}
}
And the NSLog output is correct:
Can someone tell me what's the problem? thanks!
asked 28 secs ago
Aucun commentaire:
Enregistrer un commentaire