ios - 如何使用 Swift 在 UITableView 中保存和保留选定的单元格复选标记?
问题描述
在 myscenario 中,我试图将JSON
数据加载到我的tableview
. 在这里,我在表格视图中使用多个单元格选择。我需要persist
选择单元格checkmark
。如果我去另一个视图控制器并回来查看 tableview 选择的复选标记需要显示。
我的代码
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
self.tableView.deselectRow(at: indexPath, animated: true)
let item = searching ? filteredData[indexPath.row] : membersData[indexPath.row]
if selectedRows.contains(indexPath.row) {
tableView.cellForRow(at: indexPath)?.accessoryType = .none
} else {
tableView.cellForRow(at: indexPath)?.accessoryType =
}
}
解决方案
推荐阅读
- r - shp文件打不开
- android - TextInput Bubble 不会长时间触摸:Kivy
- node.js - 使用 xml-js 解析器从 xml 转换后无法访问 json 值
- mysql - 如何在windows容器中绑定挂载数据目录
- mysql - Mysql结果表在while循环中加入多个SELECT结果
- pandas - Pandas 系列:将 DateTime 递减 100 年
- git - 如何将上游的另一个分叉分支拉入我的分叉分支?
- python - 在 kivy 框架中处理无限循环(对于数据流)
- python-3.x - 如何在 Visual Studio 代码中的奇异点/docker 图像中使用 python 解释器
- vmware - 有没有办法使用 vmware sdk - pyvmomi 以编程方式将数据存储附加到 esxi 主机