我遇到了同样的问题,并找到了两种解决方法。
1.这种方式可以同时识别Pan和Swipes,这可能是您想要的。这不是我想要的,因为我不想在页面上下滑动时改变页面。对于这种方法,您必须让您的课程成为滑动手势识别器的代表。
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return YES;
}
2.本办法防止泛从走,直到它知道舒瓦茨都失败了,这意味着刷卡绝不会在同一时间作为一个泛发生。如果你的滑动是垂直的,这只会对你有用,因为水平的滑动总是会阻止锅,我相信。
//Cheat to get the pan gesture from the pageviewcontroller. You should iterate and make sure you get the right one.
UIPanGestureRecognizer * panGR = self.pageViewController.gestureRecognizers[0];
// Add the page view controller's gesture recognizers to the book view controller's view so that the gestures are started more easily.
UISwipeGestureRecognizer * swipeGestureRec = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(openArchive:)];
swipeGestureRec.direction = UISwipeGestureRecognizerDirectionDown;
[panGR requireGestureRecognizerToFail:swipeGestureRec];
[self.view addGestureRecognizer:swipeGestureRec];
swipeGestureRec = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(closeArchive:)];
swipeGestureRec.direction = UISwipeGestureRecognizerDirectionUp;
[panGR requireGestureRecognizerToFail:swipeGestureRec];
[self.view addGestureRecognizer:swipeGestureRec];
您是否希望滑动识别器在页面视图控制器的内容区域上工作? – Macondo2Seattle
它实际上是视图控制器视图的一部分(由数据源添加)。 –