<!--
{
  "availability" : [
    "iOS: 10.0.0 - 17.0.0",
    "iPadOS: 10.0.0 - 17.0.0",
    "macCatalyst: 13.1.0 - 17.0.0",
    "tvOS: 10.0.0 - 17.0.0",
    "visionOS: 1.0.0 - 1.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UITextViewDelegate/textView(_:shouldInteractWith:in:interaction:)-622ub",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(pl)UITextViewDelegate(im)textView:shouldInteractWithURL:inRange:interaction:"
  },
  "title" : "textView(_:shouldInteractWith:in:interaction:)"
}
-->

# 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.

```
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 [`UITextItemInteraction`](/documentation/UIKit/UITextItemInteraction)).

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if interaction with the URL should be allowed; <doc://com.apple.documentation/documentation/Swift/false> if interaction should not be allowed.

## 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 ``doc://com.apple.uikit/documentation/UIKit/UITextView`` ``doc://com.apple.uikit/documentation/UIKit/UITextView/isSelectable`` property is <doc://com.apple.documentation/documentation/Swift/true> and the ``doc://com.apple.uikit/documentation/UIKit/UITextView/isEditable`` property is <doc://com.apple.documentation/documentation/Swift/false>.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)