Swift的手势点击事件和tableView点击事件冲突

解决方法:

给手势添加代理方法:

UIGestureRecognizerDelegate

extension UIViewController: UIGestureRecognizerDelegate {

func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {

if NSStringFromClass((touch.view?.classForCoder)!) == "UITableViewCellContentView" {

return false

}

return true

}

}

你可能感兴趣的:(Swift的手势点击事件和tableView点击事件冲突)