Momo1199 2013-07-31 02:25 采纳率: 0%
浏览 2109

不清楚倒计时器的问题

需要做一个倒计时器,使用NSTimeInterval。但是标签不更新啊。

- (IBAction)startTimer:(id)sender{
      timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timerAction:) userInfo:nil repeats:YES];
}

- (void)timerAction:(NSTimer *)t {

    if(testTask.timeInterval == 0){
        if (self.timer){
            [self timerExpired];
            [self.timer invalidate];
            self.timer = nil;
        }
        else {
            testTask.timeInterval--;
        }
    }

    NSUInteger seconds = (NSUInteger)round(testTask.timeInterval);
    NSString *string = [NSString stringWithFormat:@"%02u:%02u:%02u",
                        seconds / 3600, (seconds / 60) % 60, seconds % 60];
    timerLabel.text = string;
}
  • 写回答

1条回答

  • 半瓶子咣当 2013-07-31 03:13
    关注

    逻辑错误吧
    if(testTask.timeInterval != 0)

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器