textView(_:shouldInteractWith:in:)
Asks the delegate whether the specified text view allows user interaction with the specified URL in the specified range of text.
Declaration
optional func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange) -> BoolParameters
- textView:
The text view containing the text attachment.
- URL:
The URL to be processed.
- characterRange:
The character range containing the URL.
Return Value
true if interaction with the URL should be allowed; false if interaction should not be allowed.
Discussion
The text view calls this method if the user taps or long-presses the URL link. Implementation of this method is optional. By default, the text view opens the application responsible for handling the URL type and passes it the URL. You can use this method to trigger an alternative action, such as displaying the web content at the URL in a web view within the current application.