禁止你不想要的手势

只需调用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];

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容