禁止你不想要的手势

只需调用UIGestureRecoginzer 中的方法

- (void)requireGestureRecognizerToFail:(UIGestureRecognizer *)otherGestureRecognizer;

我们可以看一下这个方法的注释:

// create a relationship with another gesture recognizer that will prevent this gesture's actions from being called until otherGestureRecognizer transitions to UIGestureRecognizerStateFailed. if otherGestureRecognizer transitions to UIGestureRecognizerStateRecognized or UIGestureRecognizerStateBegan then this recognizer will instead transition to UIGestureRecognizerStateFailed .

//example usage: a single tap may require a double tap to fail 

和另一个手势创建关系,阻止另一个手势生效

具体使用方法:例如你想在有scrollView中禁止iOS7之后自带的返回手势

[self.scrollView.panGestureRecognizer requireGestureRecognizerToFail:self.navigationController.interactivePopGestureRecognizer];

你可能感兴趣的:(禁止你不想要的手势)