我正在制作一个游戏,其中有012 在UITableView
。每个10 UITableViewCells
有一个UIProgressView
加上很多其他意见。我每1/10秒更新一次UITableView
,这是非常缓慢的,滞后于旧设备。我每UX用1/10秒更新一次,给游戏带来平滑的进度感。多个UITableViewCells每个与UIProgressView更新非常缓慢
有没有办法只更新每个单元格中的进度视图,而不必调用tableView.reloadData()
来更新每个单元格中的所有视图?
代码示例:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = self.tableView.dequeueReusableCell(withIdentifier: "businessCell", for: indexPath) as! BusinessCell
cell.progress.progress = Float(businessArray[indexPath.row-1].getCurrentProgress())
//lots of other views are updated here
return cell
}
}
可能我也许改变这一行:
cell.progress.progress = Float(businessArray[indexPath.row-1].getCurrentProgress())
到这样的事情:
cell.progress.progress = someVarLocalToViewControllerContainingTableView[indexPath.row]
当我更新这个本地变量时,它只更新progressView或什么? 我已经尝试了许多方法,但无法弄清楚如何做到这一点...
当然这可能只是更新每个tableview中的进度条框架 - 这应该是正确的解决方案。重新加载整个tableview只是因为这是一场灾难。 但你也应该向我们展示你用来更新进度的代码 –