美文网首页
iOS 13.4 wkwebview 添加 UITapGestu

iOS 13.4 wkwebview 添加 UITapGestu

作者: 辣椒小鱼 | 来源:发表于2020-05-20 20:20 被阅读0次
在13.4系统中,给wkwebview添加了手势,发现手势不响应了。但是低版本都正常????
    WKWebViewConfiguration *confinguration = [[WKWebViewConfiguration alloc] init];
     confinguration.selectionGranularity = WKSelectionGranularityDynamic;
     confinguration.allowsInlineMediaPlayback = YES;
     WKPreferences *preferences = [WKPreferences new];
     preferences.javaScriptEnabled = YES;
     preferences.javaScriptCanOpenWindowsAutomatically = YES;
     confinguration.preferences = preferences;
    
    _webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height) configuration:confinguration];
    _webView.navigationDelegate = self;
    [self.view addSubview:_webView];
    
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://hike-doc-online-h5.zhihuishu.com/newStuViewer.html?WOPISrc=https://file.zhihuishu.com/zhs_yufa_150820/ablecommons/demo/202005/90a0d24e5cbc4a338c156fb471ff4654.pptx"]];
    [_webView loadRequest:request];
    
    
    //添加手势
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
    tap.delegate = self;
    [self.webView addGestureRecognizer:tap];
#pragma mark Action
- (void)tapAction:(UITapGestureRecognizer *)tap
{
    NSLog(@"@@@我被点击了");
}

#pragma mark UIGestureRecognizerDelegate
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    return YES;
}

自定义打印之后,发现响应的都在 WKChildScrollView类上边
并且手势个数不一致

//不响应
<UIScrollViewDelayedTouchesBeganGestureRecognizer: 0x283b9fc00; state = Possible; enabled = NO; delaysTouchesBegan = YES; view = <WKChildScrollView 0x11a061400>; target= <(action=delayed:, target=<WKChildScrollView 0x11a061400>)>>,
<UIScrollViewPanGestureRecognizer: 0x1198583c0; state = Possible; enabled = NO; delaysTouchesEnded = NO; view = <WKChildScrollView 0x11a061400>; target= <(action=handlePan:, target=<WKChildScrollView 0x11a061400>)>>,
<UIScrollViewKnobLongPressGestureRecognizer: 0x1198596a0; state = Possible; view = <WKChildScrollView 0x11a061400>; target= <(action=_handleKnobLongPressGesture:, target=<WKChildScrollView 0x11a061400>)>; numberOfTapsRequired = 0; minimumPressDuration = 0.1>,
<UIScrollViewKnobLongPressGestureRecognizer: 0x119844010; state = Possible; view = <WKChildScrollView 0x11a061400>; target= <(action=_handleKnobLongPressGesture:, target=<WKChildScrollView 0x11a061400>)>; numberOfTapsRequired = 0>,
<UIHoverGestureRecognizer: 0x119855240; state = Possible; view = <WKChildScrollView 0x11a061400>; target= <(action=_handleKnobHoverGesture:, target=<WKChildScrollView 0x11a061400>)>>,
<_UIDragAutoScrollGestureRecognizer: 0x28389cd20; state = Possible; cancelsTouchesInView = NO; delaysTouchesEnded = NO; view = <WKChildScrollView 0x11a061400>; target= <(action=_handleAutoScroll:, target=<WKChildScrollView 0x11a061400>)>>


//正常
<UIScrollViewDelayedTouchesBeganGestureRecognizer: 0x600001359e00; state = Possible; enabled = NO; delaysTouchesBegan = YES; view = <WKChildScrollView 0x7fcb1e036200>; target= <(action=delayed:, target=<WKChildScrollView 0x7fcb1e036200>)>>,
<UIScrollViewPanGestureRecognizer: 0x7fcb1c730640; state = Possible; enabled = NO; delaysTouchesEnded = NO; view = <WKChildScrollView 0x7fcb1e036200>; target= <(action=handlePan:, target=<WKChildScrollView 0x7fcb1e036200>)>>,
<UIScrollViewKnobLongPressGestureRecognizer: 0x7fcb1c730800; state = Possible; view = <WKChildScrollView 0x7fcb1e036200>; target= <(action=_handleKnobLongPressGesture:, target=<WKChildScrollView 0x7fcb1e036200>)>>,
<_UIDragAutoScrollGestureRecognizer: 0x6000016231e0; state = Possible; cancelsTouchesInView = NO; delaysTouchesEnded = NO; view = <WKChildScrollView 0x7fcb1e036200>; target= <(action=_handleAutoScroll:, target=<WKChildScrollView 0x7fcb1e036200>)>>

请教哪位大佬了解过??

相关文章

网友评论

      本文标题:iOS 13.4 wkwebview 添加 UITapGestu

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