ios - 重新加载表格视图并向右滑动删除
问题描述
我每 0.25 秒重新加载一次表格视图,因为我有一个计时器应用程序,但是当我从右向左滑动时删除按钮不会留在那里,因为我正在重新加载表格视图。
我该如何解决?
解决方案
无需更新可见单元格reload
。tableView
相反,循环遍历每个调用 update 方法的可见单元格:
// Example custom cell class
class MyCustomCell: UITableViewCell {
func updateTimeLabel() {
// code to update time label
}
}
在计时器方法中:
for case let cell as MyCustomCell in tableView.visibleCells {
cell.updateTimeLabel()
}
您的updateTimeLabel
方法可能需要Date
时间标签的当前值或新值等数据,因此请传递更新标签所需的数据。
推荐阅读
- regex - 从字符串中解析数字,没有空格将字母与数字分隔
- qooxdoo - 如何将较旧的主题贡献迁移到 Qooxdoo 6.0?
- docker - 本地 Gitlab cicd 使用 linux 运行程序失败“致命:无法访问...无法解析主机:...”
- javascript - 谷歌地图的新位置如何以 React 为中心?
- javascript - 谷歌应用脚本获取多个索引位置
- python - 如何解决python(Xampp)的内部服务器错误500
- amazon-web-services - 我如何配置 AWS EC2 apache 服务器
- javascript - Gatsby 中的外部 CSS/JS
- android - Android|Kotlin recyclerView 更新一项
- python - 贪心递归算法的时间复杂度