ios - 如何完全禁用 UIWebView iOS9 的放大镜

标签 ios css objective-c uiwebview ios9

我试过以下方法:

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

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

有没有人有任何不涉及在 uiwebview 的 subview 上禁用 UILongPressGestureRecognizers 的想法,如本 answer 中所建议的那样?

最佳答案

通过确保在每次页面加载后禁用手势,我设法使建议的评论起作用。

因此,在您的 webview 委托(delegate)中:

func webViewDidFinishLoad(webView: UIWebView) {
    disableLongPressGesturesForView(webView)
}

然后您的函数可以查找 webview 的每个 subview (及其 subview subview ),并禁用任何长按手势。

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

关于ios - 如何完全禁用 UIWebView iOS9 的放大镜,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32687368/

相关文章:

iOS:如何将 HTML 复制到剪切粘贴缓冲区中?

ios - 移动Safari-translation3d像素限制?

ios - 设置 UIScrollView。如果在 viewDidLayoutSubviews 中调用 UIImageView 图像会失真。包括图像

python - 如何使用 Selenium Python 获取文本颜色

jquery - 如何为多个元素设置脚本

ios - 为什么我在 Objective C 中获取 NSString 的值,例如 0xb000000000000033

iPhone 按钮选择状态

iphone - 有没有办法从新的模态视图访问启动模态视图的 View Controller ?

objective-c - 屏幕上特定位置点击事件的手势识别器

html - 最小宽度作为填充