热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何完全禁用UIWebViewiOS9的放大镜-HowtocompletelydisablemagnifyingglassforUIWebViewiOS9

Ivetriedthefollowing:我尝试过以下方法:html,body,div,p,a,table,img{-webkit-user-select:none!

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.

这适用于占据整个屏幕的uiwebview,但对于我没有的uiwebview(上面的adbannerview),它将uiwebview上方的放大镜推到了adbannerview上。

Does anyone have any ideas that don't involve disabling UILongPressGestureRecognizers on uiwebview's subviews as suggested in this answer?

有没有任何想法不涉及在uiwebview的子视图中禁用UILongPressGestureRecognizers,如本答案所示?

2 个解决方案

#1


6  

I managed to get suggested comments working by ensuring gestures are disabled after each page load.

我设法通过确保在每次加载页面后禁用手势来获得建议的评论。

So, in your webview delegate:

所以,在你的webview委托中:

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.

然后,您的函数可以查找webview的每个子视图(以及它的子视图子项),并禁用任何长按手势。

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)
    }
}

#2


2  

I disabled the magnifying glass by iterating the subviews from the webview and finding which has UILongPressGestureRegonizer then disable it

我通过迭代webview中的子视图并找到哪个具有UILongPressGestureRegonizer然后禁用它来禁用放大镜

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;
                        }
                    }
                }
            }
        }
    }
}

推荐阅读
author-avatar
zf72ayw
这个家伙很懒,什么也没留下!
Tags | 热门标签
RankList | 热门文章
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有