美文网首页iOS Developer
禁止你不想要的手势

禁止你不想要的手势

作者: 麦子_KB | 来源:发表于2016-08-17 17:14 被阅读284次

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

    相关文章

      网友评论

        本文标题:禁止你不想要的手势

        本文链接:https://www.haomeiwen.com/subject/npzgjttx.html