屏幕顶部边缘的UIScrollView UIPangestureRecognizer盲区

如下图所示,在屏幕顶部的“死区”内开始拖动时,UIPanGestureRecognizer不会平移。 这很可能是由通知中心造成的。

在这里输入图像说明

touchesMoved:withEvent:方法却被调用,所以应该有一种方法来获得在这个区域中识别的平移手势。

有没有人遇到过这个问题,那里有没有解决方法呢? 谢谢你的帮助!

有可能在屏幕的上边缘有多个干扰的手势识别器。 这可能是干扰的另一个手势识别器被系统添加了一些UIElement。

尝试在您的手势识别器委托上实现UIGestureRecognizerDelegate

特别是这种方法:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { NSLog(@"1st recognizer class: %@ ; 2nd recognizer class: %@", NSStringFromClass([gestureRecognizer class]), NSStringFromClass([otherGestureRecognizer class])); return YES; } 

https :/ / dev /

解决了这个问题。 touchesMoved:withEvent:应该这样实现:

 -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches.allObjects objectAtIndex:0]; CGPoint location = [touch locationInView:self]; CGPoint previousLocation = [touch previousLocationInView:self]; CGPoint contentOffset = self.contentOffset; contentOffset.x -= location.x - previousLocation.x; [self setContentOffset:contentOffset animated:NO]; }