gpt4 book ai didi

ios - 自定义 UITableViewCell 填充了计时器?

转载 作者:行者123 更新时间:2023-11-28 22:16:04 25 4
gpt4 key购买 nike

我在 UITableViewCell 上显示时间时遇到问题

unsigned long long seconds = milliseconds/1000;
unsigned long long minutes = seconds/60;
unsigned long long hours = minutes/60;

seconds -= minutes * 60;
minutes -= hours * 60;

NSString * result1 = [NSString `enter code here`stringWithFormat:@"%02lluH:%02lluM:%02lluS",hours,minutes,seconds];

self.menushowTime.text = result1;//populate cell label with time

每当我重新加载表格 View 时,我的计时器都会以 2 倍的速度运行,我的意思是非常快。我怎样才能防止这种情况发生。

最佳答案

facing problem when i start scrolling tableview or reloading the tableview.?

是的,它发生了,因为计时器附加到 NSRunLoop,所以当 UI 线程 忙于做动画时,NSRunLoop 必须停止。它完成动画并稍后增加您的计时器。所以计时器不会在这段时间内完美地增加。

使用下面的一个,

[[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];

关于ios - 自定义 UITableViewCell 填充了计时器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21642641/

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