From 60c9d5d41c22ee432fcb1af52057bf98b841f3b8 Mon Sep 17 00:00:00 2001 From: Ben Wheeler Date: Wed, 30 Sep 2020 11:35:32 -0400 Subject: [PATCH] updated method of disabling long press in wkwebkit --- ios/ScratchJr/src/ViewController.m | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/ios/ScratchJr/src/ViewController.m b/ios/ScratchJr/src/ViewController.m index 6e5a882..9ce111a 100644 --- a/ios/ScratchJr/src/ViewController.m +++ b/ios/ScratchJr/src/ViewController.m @@ -118,27 +118,6 @@ NSDate *startDate; 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{ NSString *callback = [NSString stringWithFormat:@"OS.loadProjectFromSjr('%@');", project]; WKWebView *webview = [ViewController webview]; @@ -171,7 +150,7 @@ NSDate *startDate; - (void) webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation { [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"];