gpt4 book ai didi

ios - 定时器 3 :30 mins which has a options with add and skip?

转载 作者:可可西里 更新时间:2023-11-01 06:06:06 25 4
gpt4 key购买 nike

我是 ios 的新手,所以我需要帮助制作一个 3:30 分钟的计时器,它有两个选项,添加和跳过,在计时器到达 00:00 后会消失。请帮助我,我现在处于非常困难的境地。

这是定时器

-(void)updatelable:(NSTimer *)timer {

remainingTime=180;

for (int i=remainingTime;i==0 ;i--) {

NSInteger minutes = floor(*(remainingTime))/ 60;
remainingTime = remainingTime-(minutes*60);

NSInteger seconds = remainingTime;

second.text =[NSString stringWithFormat:@"%02ld",seconds];
minute.text =[NSString stringWithFormat:@"%02ld",minutes];

timerLabel.text = @"Time up!!";
}

[timer invalidate];
}

最佳答案

这不是最复杂的方法,但它确实适合您,并且它准确地展示了这种方法在实践中应该如何工作:

static NSInteger remainingTime = 210;

// ...

- (void)startTimer {
[[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(counter:) userInfo:nil repeats:TRUE] fire];
}

- (void)counter:(NSTimer *)timer {
remainingTime--;

NSLog(@"%02ld:%02ld", (NSInteger)(remainingTime / 60.0), (remainingTime % 60));

if (remainingTime == 0) {
// times up!
[timer invalidate];
}
}

关于ios - 定时器 3 :30 mins which has a options with add and skip?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30099641/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com