简体   繁体   English

TextView 点击不适用于 iOS 14

[英]TextView tapping is not working on iOS 14

I have two question about textView tapping detection, first is, I know it's working well with web site urls, but if the url is the mailto url, it will open the mail app?我有两个关于textView敲击检测的问题,首先是,我知道它与网站 url 配合良好,但是如果 url 是mailto url,它会打开邮件应用程序吗?

the second and my biggest problem is, when I use Xcode 11.7 or 12 GM to run the project on iOS 13.5 device simulators, the tap on url is working well, but not mailto (it's expected), but when I run the app on iOS 14 devices and simulator, the textView detect the links, but tapping is not working at all.第二个也是我最大的问题是,当我使用 Xcode 11.7 或 12 GM 在 iOS 13.5 设备模拟器上运行项目时,点击 url 运行良好,但不是mailto (这是预期的),但是当我在 iOS 上运行应用程序时14 个设备和模拟器, textView检测到链接,但点击根本不起作用。 Is it the big from iOS 14 or something change on iOS14?是 iOS 14 的大变化还是 iOS14 的变化?

If you call gestureRecognizers on UITextField in iOS 14, it'll return you 17 (!) entities, including a few responsible for interaction with detected links:如果你在 iOS 14 的 UITextField 上调用gestureRecognizers ,它会返回17个(!)实体,包括一些负责与检测到的链接交互的实体:

  • UITextInteractionNameLinkTap UITextInteractionNameLinkTap
  • UITextInteractionNameSingleTap UITextInteractionNameSingleTap
  • UITextInteractionNameDoubleTap UITextInteractionNameDoubleTap
  • UITextInteractionNameTapAndAHalf UITextInteractionNameTapAndAHalf

They have cross-dependencies, specifically "single tap" ones are expecting the double-tap to fail.它们具有交叉依赖性,特别是“单击”的那些期望双击失败。

Indeed, taps on links did not work for me, while a double-tap would open it.事实上,点击链接对我不起作用,而双击可以打开它。

So the workaround is to remove that double-tap gesture so it does not block all the rest:所以解决方法是删除双击手势,这样它就不会阻止所有其他手势:

if let doubleTap = textView.gestureRecognizers?
    .first(where: { ($0 as? UITapGestureRecognizer)?.numberOfTapsRequired == 2 }) {
    textView.removeGestureRecognizer(doubleTap)
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM