0
有我要顯示爲這樣的計時器:00:00:00定時器不表示左0
然而,有時我的定時器顯示此:00:1:9。
有關如何阻止此問題的任何建議?
下面是代碼:
-(void)updateCounter:(NSTimer *)theTimer;{
NSTimeInterval timeInterval = [start timeIntervalSinceNow];
NSInteger secondsLeft = timeInterval;
hours = secondsLeft/3600;
minutes = (secondsLeft % 3600)/60;
seconds = (secondsLeft %3600) % 60;
_myCounterLabel.text =[[NSString stringWithFormat:@"%02d:%02d:%02d", hours, minutes, seconds] stringByReplacingOccurrencesOfString:@"-" withString:@""];
NSLog(@"%f interval", timeInterval);
}