Merge pull request #330 from LLK/fix-wkwebkit-context-menu

updated method of disabling long press in wkwebkit
This commit is contained in:
Benjamin Wheeler 2020-10-05 11:15:18 -04:00 committed by GitHub
commit 203a4eeec4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -118,27 +118,6 @@ NSDate *startDate;
startDate = [NSDate date]; startDate = [NSDate date];
} }
// Disables iOS 9 webview touch tooltip by disabling the long-press gesture recognizer in subviews
// Thanks to Rye:
// http://stackoverflow.com/questions/32687368/how-to-completely-disable-magnifying-glass-for-uiwebview-ios9
- (void) disableWebViewLongPressGestures:(WKWebView *)webview {
for(id subView in webview.subviews) {
if([subView isKindOfClass:[UIScrollView class]]) {
UIScrollView *scrollView = (UIScrollView *)subView;
for(id ssView in scrollView.subviews) {
if([NSStringFromClass([ssView class]) isEqualToString:@"UIWebBrowserView"]) {
for(UIGestureRecognizer *gs in [ssView gestureRecognizers]) {
if ([gs isKindOfClass:[UILongPressGestureRecognizer class]])
{
gs.enabled = NO;
}
}
}
}
}
}
}
- (void) receiveProject:(NSString *)project{ - (void) receiveProject:(NSString *)project{
NSString *callback = [NSString stringWithFormat:@"OS.loadProjectFromSjr('%@');", project]; NSString *callback = [NSString stringWithFormat:@"OS.loadProjectFromSjr('%@');", project];
WKWebView *webview = [ViewController webview]; WKWebView *webview = [ViewController webview];
@ -171,7 +150,7 @@ NSDate *startDate;
- (void) webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation { - (void) webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
[webview evaluateJavaScript:@"window.tablet = window.webkit.messageHandlers.jsBridge" completionHandler:nil]; [webview evaluateJavaScript:@"window.tablet = window.webkit.messageHandlers.jsBridge" completionHandler:nil];
[self disableWebViewLongPressGestures:webView]; [webview evaluateJavaScript:@"document.body.style.webkitTouchCallout='none';" completionHandler:nil];
NSString *debugChoice =[[NSUserDefaults standardUserDefaults] stringForKey:@"debugstate"]; NSString *debugChoice =[[NSUserDefaults standardUserDefaults] stringForKey:@"debugstate"];