You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何禁用WKWebView中双击长按触发的放大镜功能?

如何禁用WKWebView中双击和长按触发的放大镜功能?

我已经为页面所有元素设置了user-select: none,但双击或长按WKWebView中的内容时,仍然会出现放大镜功能,效果如下:

放大镜效果截图

HTML代码

<html>
<head>
    <meta name="viewport" content="viewport-fit=cover, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, width=device-width"> 
    <meta name="apple-mobile-web-app-capable" content="yes">
</head>
<style>
* {
    -webkit-user-drag: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0) !important;
    user-select: none;
}
body {
    background: green;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}
</style>
<body>
    TEST
</body>
</html>

Swift代码

import UIKit
import WebKit

class ViewController: UIViewController, WKUIDelegate, WKNavigationDelegate {

    var webView: WKWebView!

    override func viewDidLoad() {
        super.viewDidLoad()

        let webConfiguration = WKWebViewConfiguration()
        webView = WKWebView(frame: .zero, configuration: webConfiguration)
        webView.uiDelegate = self
        webView.navigationDelegate = self

        if let myURL = URL(string: "*") {
            let myRequest = URLRequest(url: myURL)
            webView.load(myRequest)
        }
    }

    func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
        self.view = webView
    }
    override var prefersHomeIndicatorAutoHidden: Bool {
        return true
    }
}

请问有没有人遇到过这个问题?求可行的解决方案。


内容的提问来源于stack exchange,提问作者Vector

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 00:22:06