Ios UITableView未选择在swift 3.0中不工作

Ios UITableView未选择在swift 3.0中不工作,ios,iphone,swift,Ios,Iphone,Swift,当我选择任何行时,不会调用didselect。它的颜色在选择时也会变为蓝色。但didSelect不工作。委托、数据源和表出口也已连接。这是我的密码: func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { categoryLbl.text = categoryArray[indexPath.row].type dataDict.setValue(categoryArray[i

当我选择任何行时,不会调用didselect。它的颜色在选择时也会变为蓝色。但didSelect不工作。委托、数据源和表出口也已连接。这是我的密码:

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)

}
试试这个

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

categoryLbl.text = categoryArray[indexPath.row].type
    dataDict.setValue(categoryArray[indexPath.row].type, forKey: "category")
    categoryTable?.isHidden = true

}

试试这个,它会解决你的问题

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
    }
}

是否设置了断点并进行了一次测试。是否已将视图与视图控制器连接..?是否不包含此类别表?isHidden=true tryonce@TusharSharma是的,我试过了。@AnilKumar除了didSelect和tableOutlet已连接外,其他一切都正常工作。不工作。它也不工作,因为此代码适用于swift 2.3,我正在使用Swift 3.但问题是,以前它工作正常,但突然停止工作。因为当您添加UITapGestureRecognitizer()时,轻触手势正在吞噬您的所有触摸事件。好的,非常感谢:)快乐编码:-)