第一种: OC之后常用的iskindof
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
NVRLOG(touch.view)
if (touch.view?.isKind(of:UITableView.self))! {
return false
}
return true
}
第二种: 通过类名字符串判断,适用于那种不知道类名的。
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
NVRLOG(touch.view)
if NSStringFromClass((touch.view?.classForCoder)!) == "UITableViewCellContentView" {
return false
}
return true
}
第三种:OC没有的语法
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
NVRLOG(touch.view)
if touch.view is UITableView {
return false
}
return true
}
注:只为记录。
原文链接:https://cloud.tencent.com/developer/article/1383422