UITapGestureRecognizer 和 UICollectionView/UITableView等点击事件冲突问题
作者:互联网
在gestureRecognizer方法中,利用isDescendantOfView来判断当前点击区域是否是collectionView/tableView,若是,则返回NO,忽略该手势的点击事件,否则返回YES。
先添加代理 UIGestureRecognizerDelegate ,再判断触摸点在触摸视图时禁用此 tap
#pragma mark - UIGestureRecognizerDelegate - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { if ([touch.view isDescendantOfView:self.collectionView]) { return NO; } return YES; }
标签:gestureRecognizer,UICollectionView,UITapGestureRecognizer,点击,isDescendantOfView, 来源: https://www.cnblogs.com/huangzs/p/15043312.html