Ios UITableView上未触发触摸事件
因此,在我的主UIViewController中有3个不同的UITableView,我通过一个开关控制de内容,该开关评估它在“cellForRowAt”中的哪个tableview,但3个表中只有2个触发“didSelectRowAt indexPath”事件Ios UITableView上未触发触摸事件,ios,swift,uitableview,Ios,Swift,Uitableview,因此,在我的主UIViewController中有3个不同的UITableView,我通过一个开关控制de内容,该开关评估它在“cellForRowAt”中的哪个tableview,但3个表中只有2个触发“didSelectRowAt indexPath”事件 func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { switch tableView { case chec
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时,会调用该方法,但对于此特定表,则不会调用该方法
我还设置了表的委托和数据源
据我所知,您的代码没有问题,但可能有一些地方您遗漏了,我在阅读您的文本时无法理解。以下是一种简单的替代方法,它可以帮助您
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if (tableView.tag == 200) {
//checkoutTable
}
if (tableView.tag == 201) {
//clientTable
}
if (tableView.tag == 202) {
//your third table
}
}
我希望这能帮助您。检查属性检查器中的选择是否为单一选择而不是无选择。也只需在viewDidLoad中启用tableview的选择
tableView.allowsSelection = true
首先,您是否正确设置了
签出表的委托
?是的,在您的表视图及其表视图单元格上将postIs userIneractionEnabled设置更新为true?是的,检查了它们并重新检查了它们。问题是,单击此特定表时,不会调用事件