在 WKWebView 中禁用图像选择
我使用 WKWebView 在我的应用程序中显示 Web 内容。我想让内容尽可能地让人感觉本土化。
我已经将此 CSS 添加到 WKWebView 中加载的网站中:
* {
-webkit-user-select: none;
-webkit-touch-callout: none;
}
不过,当长时间点击图像时,可以“选择并移动它们”。
我怎样才能防止这种情况发生?
附: 在 iOS 15.1 上,当点击文本时,会出现文本放大镜。 iOS 15.3.1 中不会发生这种情况。
I use a WKWebView to display web content in my app. I want to make the content to feel as native as possible.
I've already added this CSS to the web site loaded in the WKWebView:
* {
-webkit-user-select: none;
-webkit-touch-callout: none;
}
Still, when long tapping on images, they can be "selected and moved around".
How can I prevent this?
PS:
On iOS 15.1 when log tapping on text, the text magnification glass appears. This doesn't happen in iOS 15.3.1.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过两种方式做到这一点(在 iOS 15.5 上测试):
1:CSS
2:HTML
You can do that in two ways (tested on iOS 15.5):
1: CSS
2: HTML