Ios 重新加载rowsatindexpaths会导致单元格闪烁或闪烁
我有一个tableview,其中每个单元格都可以播放音频文件。我正在尝试复制语音备忘录程序中的单元格: 我使用UISlider来提供播放条,我有当前时间和剩余时间的文本标签。我希望在播放时更新单元格中的数据 要设置UISlider的动画,我调用以下方法:Ios 重新加载rowsatindexpaths会导致单元格闪烁或闪烁,ios,uitableview,swift,timer,Ios,Uitableview,Swift,Timer,我有一个tableview,其中每个单元格都可以播放音频文件。我正在尝试复制语音备忘录程序中的单元格: 我使用UISlider来提供播放条,我有当前时间和剩余时间的文本标签。我希望在播放时更新单元格中的数据 要设置UISlider的动画,我调用以下方法: UIView.animateWithDuration(Double(player.duration) - Double(player.currentTime), delay: 0, options: .AllowUserInteraction
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)
是否有一种方法可以更新单元格中的值,而无需调用
reloadrowsatindexpath
?存储对要更新标签的单元格(nsindepath)的引用,然后直接编辑它们
返回指定索引路径处的表单元格
- (UITableViewCell*)cellForRowAtIndexPath:(NSIndexPath*)indexPath 参数 索引 在接收器中定位行的索引路径
SomeCell *cell = (SomeCell*)[self.yourTableView cellForRowAtIndexPath:_yourStoredIndexPath];
cell.someLabel.text = @"Some text";