我试过以下方法:
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/