1
我有一個倒數計時器,用戶可以輸入他們想要使用倒數計時器的時間,如在時鐘應用程序中。問題是,我無法弄清楚如何讓計時器倒計時。我已經制作了UI並擁有大部分代碼,但我不知道updateTimer
方法中會出現什麼結果。這裏是我的代碼:如何在目標c中完成我的倒數計時器?
- (void)updateTimer
{
//I don't know what goes here to make the timer decrease...
}
- (IBAction)btnStartPressed:(id)sender {
pkrTime.hidden = YES; //this is the timer picker
btnStart.hidden = YES;
btnStop.hidden = NO;
// Create the timer that fires every 60 sec
stopWatchTimer = [NSTimer scheduledTimerWithTimeInterval:1.0
target:self
selector:@selector(updateTimer)
userInfo:nil
repeats:YES];
}
- (IBAction)btnStopPressed:(id)sender {
pkrTime.hidden = NO;
btnStart.hidden = NO;
btnStop.hidden = YES;
}
請讓我知道在updateTimer
方法讓計時器減少發生的事情。
在此先感謝。
什麼變化你有跟蹤時間?我沒有看到它的變量,或者是你要求的嗎? –