这是我要归档的内容:当点击第二个中文行时取消选择“英文”行,反之亦然。
我只想显示一个复选标记,而不是全部。这是我的代码:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if tableView.cellForRow(at: indexPath)!.accessoryType == .checkmark {
tableView.cellForRow(at: indexPath)!.accessoryType = .none
navigationItem.rightBarButtonItem!.isEnabled = false
} else if tableView.cellForRow(at: indexPath)!.accessoryType == .none {
tableView.cellForRow(at: indexPath)!.accessoryType = .checkmark
navigationItem.rightBarButtonItem!.isEnabled = true
}
}
最佳答案
我终于得到了答案。给你:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.cellForRow(at: indexPath)!.accessoryType = .checkmark
navigationItem.rightBarButtonItem?.isEnabled = true
}
func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
tableView.cellForRow(at: indexPath)!.accessoryType = .none
navigationItem.rightBarButtonItem?.isEnabled = false
}
关于ios - 如何在点击另一行时取消选择一行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47533152/