【发布时间】:2014-11-07 19:48:29
【问题描述】:
我有一个表格视图,其中每个单元格都可以播放音频文件。我正在尝试复制语音备忘录程序中的单元格:
我正在使用 UISlider 提供播放栏,并且我有当前时间和剩余时间的文本标签。我希望在播放时更新单元格中的数据。
要为 UISlider 设置动画,我调用该方法:
UIView.animateWithDuration(Double(player.duration) - Double(player.currentTime), delay: 0, options: .AllowUserInteraction | .BeginFromCurrentState, animations: {
cell.audioSlider.setValue(Float(self.duration) - Float(self.player.currentTime), animated: true)
self.startToPlay = false
}, completion: { _ in
cell.audioSlider.setValue(Float(self.player.currentTime), animated: true)})
在我使用计时器的时候:
timer = NSTimer.scheduledTimerWithTimeInterval(NSTimeInterval(interval), target: self, selector: "updateProgressBar:", userInfo: nil, repeats: true)
updateProgressBar 函数用于更新文本标签。 如果我在计时器的每个间隔调用 reload 方法,那么单元格就会闪烁。
tableView.reloadRowsAtIndexPaths([currentCellIndexPath], withRowAnimation: .Automatic)
有没有办法在不调用reloadRowsAtIndexPaths的情况下更新单元格中的值?
【问题讨论】:
标签: ios uitableview swift timer