适用于UITableviewcell的NSTimer与World Clock应用类似 [英] NSTimer for UITableviewcell similar to World Clock app
问题描述
我想在UITableview中构建一些简单的倒数计时器.我注意到World Clock应用程序的每一行都有动画时钟.触发NSTimer更新每个表行的最佳方法是什么?可以运行一个计时器来更新所有单元格吗?还是我应该将具有内置计时器的自定义视图子类添加到每一行中?
I would like to build a few simple countdown timers in a UITableview. I noticed the World Clock app has animated clocks in each of it's rows. What is the best method to firing an NSTimer to update each table row? Can a single timer be run that updates all cells or should I have a custom view subclass with built in timer that is added to each row?
我只是在尝试采取适当的措施.
I am just trying to get a proper course of action.
推荐答案
一个计时器就足够了.触发时,向表格视图询问可见的单元格,然后对其进行逐一更新.您也可以在计时器触发时仅调用reloadData
,但是根据绘制单元格的方式,您可能会做更多的工作,并且无法使用动画.
One timer is sufficient. When it fires, ask the table view for the visible cells and update them one by one. You could also just call reloadData
when the timer fires but depending on how you draw your cells you might do more work than necessary and you cannot use animations.
这篇关于适用于UITableviewcell的NSTimer与World Clock应用类似的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!