<分区>
我有一个非常简单的 5 行表格设置用于设置屏幕。每当单击第一个单元格时,它会突出显示但不会调用 didselectrow。如果我单击不同的行,该行将调用 did select 函数但返回不正确的行。然后我可以单击第一行,它会返回但也有一个不正确的行。我在项目中设置了几个与此类似的表,但它们没有这种行为。单元格正确突出显示,所以我不认为我有布局/ View 问题。我没有任何约束警告,当我使用 viewdebugger 时,我没有遇到任何覆盖表格单元格的 View 。感谢所有帮助!
let settingsArray:[String] = ["Notifications","Account","bar","Help","Privacy Policy"]
extension SettingsViewController: UITableViewDataSource,UITableViewDelegate {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return settingsArray.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
print("\(indexPath.row) setting \(settingsArray[indexPath.row])")
if settingsArray[indexPath.row] != "bar" {
let cell = tableView.dequeueReusableCell(withIdentifier: "settingOption") as! SettingsOptionCell
cell.configure(setting: settingsArray[indexPath.row])
self.settingsTable.rowHeight = 65
cell.isUserInteractionEnabled = true
return cell
} else {
let cell = tableView.dequeueReusableCell(withIdentifier: "settingBar")
self.settingsTable.rowHeight = 70
cell?.isUserInteractionEnabled = false
return cell!
}
}
func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
print("clicked \(indexPath.row)")
}
}