WKWebview 允许LinkPreview 错误地中断文本选择 [英] WKWebview allowsLinkPreview to false breaks text selection

查看:26
本文介绍了WKWebview 允许LinkPreview 错误地中断文本选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个使用 WKWebview 的应用,但将 allowsLinkPreview 设置为 false,因为我们不想要链接预览行为.似乎从 iOS 13.4 开始,在具有 3D 触摸功能的设备(较旧的设备和较新的 iPhone 型号)上,将 allowsLinkPreview 设置为 false 禁用页面中的所有文本选择!对于我们的应用,文本选择至关重要.

We have an app that uses WKWebview, but sets allowsLinkPreview to false because we don't want link preview behavior. It seems that starting with iOS 13.4, on devices that don't have 3D touch functionality (older devices and newer iphone models), setting allowsLinkPreview to false also disables all text selection in the page! For our app, text selection is critically important.

我想出了这个理论阅读在文档中:

在 iOS 中,此属性在支持 3D Touch 的设备上可用.

In iOS this property is available on devices that support 3D Touch.

在运行 iOS 13 及更高版本的设备上,无论设备是否支持 3D Touch,人们都可以使用长按手势打开上下文菜单.在 3D Touch 设备上,手势可以更快地显示上下文菜单.

On devices running iOS 13 and later, people can use the touch and hold gesture to open a context menu, regardless of whether the device supports 3D Touch. On 3D Touch devices, the gesture can reveal the context menu more quickly.

这似乎是一个错误,禁用链接预览会禁用所有 webview 中的按住手势.

It seems like a bug that disabling link preview disables all press and hold gestures in the webview.

我能想到的唯一解决方法是将 allowsLinkPreview 设置为 true,然后通过 WKUIDelegate 协议.这将禁用单击链接的弹出窗口,但不会禁用单击图像的弹出窗口.而且,它仍然允许用户将链接拖放到 safari 中的分屏视图中,这是我们不希望的.

The only workaround I've been able to come up with is to set allowsLinkPreview to true, and then disabling the context menu via the WKUIDelegate protocol. This disables the popup for clicked links, but does not disable the popup for clicked images. And, it still allows users to drag-drop the link into a split screen view in safari, which we do not want.

关于如何完全禁用链接预览/上下文菜单/拖放行为同时仍然允许文本选择的任何建议将不胜感激!

Any suggestions for how to completely disable link preview/context menu/drag-drop behavior while still allowing text selection would be appreciated!

更新
由于我控制了我的应用程序的内容,因此我可以使用以下 css 禁用按住图像的功能:-webkit-touch-callout: none; 所以我剩下的问题只是禁止拖动来自 WKWebView 的应用程序外的交互.

UPDATE
Since I control the content of my app, I was able to disable press-hold of images by using the following css: -webkit-touch-callout: none; So my remaining problem is just to disallow drag interactions out of the app from the WKWebView.

更新 2类似地,我能够使用 -webkit-user-drag: none; 来禁用链接的拖动,但是知道对我来说似乎像 Apple 的非 css 修复程序仍然很有用错误.

UPDATE 2 Similarly, I was able to use -webkit-user-drag: none; to disable dragging of links, but it would still be useful to know a non-css fix for what seems to me like an Apple bug.

推荐答案

这可能与一个已知的 Webkit 错误有关,该错误可能已经修复(在撰写本文时):

This may be related to a known Webkit bug that is presumably already fixed (as of this writing):

https://bugs.webkit.org/show_bug.cgi?id=210191

这篇关于WKWebview 允许LinkPreview 错误地中断文本选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆