0
我在UICollectionView
的单元格上实现了一个倒数计时器,我从web服务获得时间,但是它显示静态时间,当我回到UICollectionView
时,根据剩余的Web服务时间减少了课程时间。如何在UICollectionViewCell上使用实时定时器?
但是我想在每次减少一秒钟时显示它,任何帮助表示赞赏。
我的代码:
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell
{
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! ManageObjectCollectionViewCell
revealTime = getRevealtime[indexPath.section].objectAtIndex(indexPath.row) as! Int
minutes = revealTime/60
seconds = revealTime % 60
cell.HourLabel.text = "0"
cell.MinLabel.text = NSString(string: "\(minutes)") as String
cell.sec.text = NSString(string: "\(seconds)") as String
}
真不明白。你能用例子更好地解释吗? – Shubhank
当需要更新时,您是否有'NSTimer'对象或其他计时器触发 - (从Web服务获取新时间或根据您已有的信息计算)。获取新时间后,您将重新加载指定索引处的单元格,或重新加载所有单元格(取决于您的需要)。 – DJohnson