当我选择任何行时,没有调用 didselect。它的颜色也会在选择时变为蓝色。但 didSelect 不起作用。Delegate、DataSources 和 Table 导出也已连接。这是我的代码:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
categoryLbl.text = categoryArray[indexPath.row].type
dataDict.setValue(categoryArray[indexPath.row].type, forKey: "category")
categoryTable?.isHidden = true
}
override func viewDidLoad() {
super.viewDidLoad()
imagePicker.delegate = self
NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardNotification(notification:)), name: NSNotification.Name.UIKeyboardWillChangeFrame, object: nil)
categoryTable?.isHidden = true
self.geCategoryData()
let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action:#selector(AddFeedbackViewController.dismissKeyboard))
view.addGestureRecognizer(tap)
}
最佳答案
试试这个,它会解决你的问题
tap.delegate = self // add this in viewdidLoad()
extension YourViewContoller: UIGestureRecognizerDelegate {
func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch touch: UITouch) -> Bool {
if touch.view != nil && touch.view!.isDescendantOfView(self.tableView) {
return false
}
return true
}
}
关于ios - UITableView didSelect 在 swift 3.0 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43025900/