Ios 在WKWebView中滑动手势
因此,我在Ios 在WKWebView中滑动手势,ios,objective-c,uiwebview,wkwebview,Ios,Objective C,Uiwebview,Wkwebview,因此,我在UICollectionViewCell中有一个WKWebView。我必须打开几个网页,但这些网页正在通过覆盖touchmove事件消耗滚动,如下所示: document.addEventListener('touchmove', function(e) { e.preventDefault(); } 我已尝试将滑动手势添加到WKWebView及其superview触摸移动:在superview中也不会被调用。我无法在webview上禁用用户交互,因为我希望能够点击并与web
UICollectionViewCell
中有一个WKWebView
。我必须打开几个网页,但这些网页正在通过覆盖touchmove
事件消耗滚动,如下所示:
document.addEventListener('touchmove', function(e) {
e.preventDefault();
}
我已尝试将滑动手势添加到WKWebView
及其superview
<代码>触摸移动:在superview中也不会被调用。我无法在webview上禁用用户交互
,因为我希望能够点击并与webview交互
我尝试通过注入脚本覆盖网页的现有touchmove
事件:
WKUserScript *script = [[WKUserScript alloc]initWithSource:@"window.ontouchmove = function() { \
window.webkit.messageHandlers.touchmoved.postMessage('Touches Moved..'); \
return true; \
};" injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:NO];
WKUserScript *docscript = [[WKUserScript alloc]initWithSource:@"document.ontouchmove = function() { \
window.webkit.messageHandlers.touchmoved.postMessage('Doc Touches Moved..'); \
return true; \
};" injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:NO];
[config.userContentController addUserScript:script];
[config.userContentController addUserScript:docscript];
[config.userContentController addScriptMessageHandler:self name:@"touchmoved"];
我在didReceiveScriptMessage
中收到回调,但它无法启用滚动
有没有办法为这些网页启用滚动或添加滑动手势