美文网首页
互动白板阻截父视图的tap事件

互动白板阻截父视图的tap事件

作者: 今年27 | 来源:发表于2020-09-25 13:43 被阅读0次

    iOS13.4之后, 互动白板会拦截掉superView的tap事件。
    丛原理上看, 白板是WKWebView,理论上来子视图是无法拦截父视图的tap事件的,
    但是互动白板就是这么操蛋
    于是乎,我开始遍历白板中的所有事件,从中辨别究竟是什么事件拦截掉父视图的tap事件,
    经过一番寻找之后

    2020-07-30 10:35:49.012864+0800 PALAISell_Example[60059:1173534] other Fail:UIVariableDelayLoupeGesture
    2020-07-30 10:35:49.012935+0800 PALAISell_Example[60059:1173534] other Fail:UITextTapRecognizer
    2020-07-30 10:35:49.012966+0800 PALAISell_Example[60059:1173534] other Fail:UITapGestureRecognizer
    2020-07-30 10:35:49.012991+0800 PALAISell_Example[60059:1173534] other Fail:UITapAndAHalfRecognizer
    2020-07-30 10:35:49.013016+0800 PALAISell_Example[60059:1173534] other Fail:UITextTapRecognizer
    2020-07-30 10:35:49.013039+0800 PALAISell_Example[60059:1173534] other Fail:_UIContextualMenuGestureRecognizer
    2020-07-30 10:35:49.013062+0800 PALAISell_Example[60059:1173534] other Fail:_UIRelationshipGestureRecognizer
    2020-07-30 10:35:49.013083+0800 PALAISell_Example[60059:1173534] other Fail:UITapGestureRecognizer
    2020-07-30 10:35:49.013276+0800 PALAISell_Example[60059:1173534] other Fail:WKTouchActionGestureRecognizer
    2020-07-30 10:35:49.013429+0800 PALAISell_Example[60059:1173534] other Fail:UITapGestureRecognizer
    2020-07-30 10:35:49.013622+0800 PALAISell_Example[60059:1173534] other Fail:_UITextSelectionForceGesture
    2020-07-30 10:35:49.013757+0800 PALAISell_Example[60059:1173534] other Fail:UIWebTouchEventsGestureRecognizer
    2020-07-30 10:35:49.013873+0800 PALAISell_Example[60059:1173534] other Fail:_UITouchDurationObservingGestureRecognizer
    2020-07-30 10:35:49.013996+0800 PALAISell_Example[60059:1173534] other Fail:UITapGestureRecognizer
    2020-07-30 10:35:49.014102+0800 PALAISell_Example[60059:1173534] other Fail:_UISecondaryClickDriverGestureRecognizer
    2020-07-30 10:35:49.014247+0800 PALAISell_Example[60059:1173534] other Fail:WKSyntheticTapGestureRecognizer
    2020-07-30 10:35:49.014391+0800 PALAISell_Example[60059:1173534] other Fail:_UIRelationshipGestureRecognizer
    2020-07-30 10:35:49.014498+0800 PALAISell_Example[60059:1173534] other Fail:WKDeferringGestureRecognizer
    

    最终锁定UIWebTouchEventsGestureRecognizer, 自己尝试之后发现这个手势有点类似UILongPressGestureRecognizer, 所以可以区分点击和长按

    - (void)showGestureRecognizers:(UIView*)view{
    
        for (UIGestureRecognizer *gesture in view.gestureRecognizers)
        {
            NSLog(@"gesture:%@", gesture);
            if ([gesture.className isEqualToString:@"UIWebTouchEventsGestureRecognizer"]) {
    //            r.delegate = self;
                [gesture addTarget:self action:@selector(longPressEvent:)];
            }
        }
         
        for (UIView *v in view.subviews){
            [self showGestureRecognizers:v];
    
        }
    
    }
    
    - (void)incrementCounter {
        self.counter++;
    }
    
    
    

    相关文章

      网友评论

          本文标题:互动白板阻截父视图的tap事件

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