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