今天有人問我collectionView 的左滑和 cell中的左滑手勢(shì)沖突怎么處理
目前有兩個(gè)處理方式 適用于 UIscrollView UItableView UICollection 等
1.讓手勢(shì)共同存在
```
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
NSLog(@"當(dāng)前手勢(shì):%@; 另一個(gè)手勢(shì):%@", gestureRecognizer, otherGestureRecognizer);
return YES;
}
```
2.使用hitTest響應(yīng)者鏈
```
-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
NSString *className=NSStringFromClass([[super hitTest:point withEvent:event] class]);
if ([className isEqualToString:@"你的含有手勢(shì)的類名"]) {
self.collectionView.scrollEnabled=NO;
return [super hitTest:point withEvent:event];
}
else
{
self.collectionView.scrollEnabled=YES;
return [super hitTest:point withEvent:event];;
}
}
```