I\'m using the UITextView
delegate method to do some custom work like opening a in-app browser when user tapping on URL or attachment:
I just encountered the same frustrating issue in iOS 13. Here is a fix that worked for me in Swift inspired by Mihai's answer above.
func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
switch interaction {
case .invokeDefaultAction:
if textView.gestureRecognizers?.contains(where: {$0.isKind(of: UITapGestureRecognizer.self) && $0.state == .ended}) == true {
// Handle your custom logic here.
return false
}
return true
case .presentActions:
// Default action.
return true
case .preview:
// Default action.
return true
@unknown default:
fatalError()
}
}