TextView tapping is not working on iOS 14

Viewed 410

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?

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. Is it the big from iOS 14 or something change on iOS14?

1 Answers

If you call gestureRecognizers on UITextField in iOS 14, it'll return you 17 (!) entities, including a few responsible for interaction with detected links:

  • UITextInteractionNameLinkTap
  • UITextInteractionNameSingleTap
  • UITextInteractionNameDoubleTap
  • 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)
}
Related