I've tried the following:
html, body, div, p, a, table, img
{
-webkit-user-select: none !important;
user-select: none !important;
-webkit-user-callout: none !important;
-webkit-touch-callout: none !important;
}
This works for my uiwebview that takes up the whole screen, but for my uiwebview that does not (adbannerview above), it pushes the magnifying glass above the uiwebview over the adbannerview.
Does anyone have any ideas that don't involve disabling UILongPressGestureRecognizers
on uiwebview's subviews as suggested in this answer?
I managed to get suggested comments working by ensuring gestures are disabled after each page load.
So, in your webview delegate:
func webViewDidFinishLoad(webView: UIWebView) {
disableLongPressGesturesForView(webView)
}
Then your function can look up each subview of the webview (and it's subview children), and disable any long press gestures.
func disableLongPressGesturesForView(view: UIView) {
for subview in view.subviews {
if let gestures = subview.gestureRecognizers as [UIGestureRecognizer]! {
for gesture in gestures {
if gesture is UILongPressGestureRecognizer {
gesture.enabled = false
}
}
}
disableLongPressGesturesForView(subview)
}
}
I disabled the magnifying glass by iterating the subviews from the webview and finding which has UILongPressGestureRegonizer then disable it
Here is the snippet :
- (void)disableWebViewLongPressGestures:(UIWebView *)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;
}
}
}
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With