Instance Method

textView(_:shouldInteractWith:in:)

Asks the delegate if the specified text view should allow user interaction with the provided text attachment in the given range of text.

Declaration

optional func textView(_ textView: UITextView, shouldInteractWith textAttachment: NSTextAttachment, in characterRange: NSRange) -> Bool

Parameters

textView

The text view containing the text attachment.

textAttachment

The text attachment.

characterRange

The character range containing the text attachment.

Return Value

true if interaction with the text attachment should be allowed; false if interaction should not be allowed.

Discussion

A text view calls this method if the user taps or long-presses the text attachment and its image property is not nil. Implementation of this method is optional. You can use this method to trigger an action in addition to displaying the text attachment inline with the text.

See Also

Interacting with Text Data

func textView(UITextView, shouldInteractWith: NSTextAttachment, in: NSRange, interaction: UITextItemInteraction) -> Bool

Asks the delegate if the specified text view should allow the specified type of user interaction with the provided text attachment in the given range of text.

func textView(UITextView, shouldInteractWith: URL, in: NSRange, interaction: UITextItemInteraction) -> Bool

Asks the delegate if the specified text view should allow the specified type of user interaction with the given URL in the given range of text.

func textView(UITextView, shouldInteractWith: URL, in: NSRange) -> Bool

Asks the delegate if the specified text view should allow user interaction with the given URL in the given range of text.

Deprecated