---
title: "textView(_:shouldInteractWith:in:interaction:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uitextviewdelegate/textview(_:shouldinteractwith:in:interaction:)-622ub"
---

# textView(_:shouldInteractWith:in:interaction:)

Asks the delegate whether the specified text view allows the specified type of user interaction with the specified URL in the specified range of text.

## Declaration

```swift
optional func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool
```

## Parameters

- `textView`: The text view containing the text attachment.
- `URL`: The URL to be processed.
- `characterRange`: The character range containing the URL.
- `interaction`: The type of interaction that is occurring (for possible values, see doc://com.apple.uikit/documentation/UIKit/UITextItemInteraction).

## Return Value

Return Value true if interaction with the URL should be allowed; false if interaction should not be allowed.

## Discussion

Discussion This method is called on only the first interaction with the URL link. For example, this method is called when the user wants their first interaction with a URL to display a list of actions they can take; if the user chooses an open action from the list, this method is not called, because “open” represents the second interaction with the same URL. important: Links in text views are interactive only if the text view is selectable but noneditable. That is, if the value of the UITextView isSelectable property is true and the isEditable property is false.

## See Also

### Deprecated

- [textView(_:shouldInteractWith:in:interaction:)](uikit/uitextviewdelegate/textview(_:shouldinteractwith:in:interaction:)-5qha9.md)
- [textView(_:shouldInteractWith:in:)](uikit/uitextviewdelegate/textview(_:shouldinteractwith:in:)-97zx6.md)
- [textView(_:shouldInteractWith:in:)](uikit/uitextviewdelegate/textview(_:shouldinteractwith:in:)-98tho.md)
- [UITextItemInteraction](uikit/uitextiteminteraction.md)
