【发布时间】:2017-01-07 21:53:39
【问题描述】:
所以,我的主 UIViewController 中有 3 个不同的 UITableView,我使用 SWITCH 控制内容,评估它在“cellForRowAt”中的哪个表视图,但 3 个表中只有 2 个触发了“didSelectRowAt indexPath”事件。
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
switch tableView {
case checkoutTable:
//THIS RIGHT HERE IS NEVER EXECUTED
if (indexPath as NSIndexPath).row == 0 {
if self.calculateTotalsInCart() > 0 {
performSegue(withIdentifier: "sgAddDescount", sender: self)
}else{
let alert:UIAlertController = UIAlertController(title: "Descuento Inaplicable", message: "No puedes aplicar descuento a una cuenta en ceros", preferredStyle: UIAlertControllerStyle.alert)
let okButton:UIAlertAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
alert.addAction(okButton)
self.present(alert, animated: true, completion: nil)
}
}
break
case clientTable:
if (indexPath as NSIndexPath).row == 0 {
performSegue(withIdentifier: "clientSelection", sender: self)
}
break
default:
print("None Selected")
break;
}
}
当我点击任何其他 UITableView 时,该方法被调用,但对于这个特定的表,它不是。
我也设置了表的委托和数据源
【问题讨论】:
-
首先你是否正确设置了
checkoutTable的delegate? -
是的,更新了帖子
-
表格视图和表格视图单元格的 userIneractionEnabled 是否都设置为 true?
-
是的,检查过并重新检查过
标签: ios swift uitableview