【发布时间】:2016-11-30 22:05:54
【问题描述】:
我不明白为什么我不能切换选定的表格行。 我在 didSelectRowAt 中成功设置了附件类型。 但我似乎无法在 didDeselectRowAt 中将 accessoryType 设置为 none。
我的数据:
serviceItems = ["Heater", "Air Conditioner", "Boiler", "Heat Pump"]
这是我的 tableview 覆盖:
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
cell.accessoryType = .checkmark
let serviceItem = serviceItems[indexPath.row] as! String
cell.textLabel?.text = serviceItem
}
// does not remove checkmark
// does not change textLabel to "test"
// DOES print "DESELECTING" (so I know its getting called)
override func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
cell.accessoryType = .none
cell.textLabel?.text = "test"
print("DESELECTING")
}
【问题讨论】:
-
@theMikeSwan 你有答案,如果你想发布它
标签: ios swift uitableview swift3 didselectrowatindexpath