<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "tvOS: -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UITextViewDelegate",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(pl)UITextViewDelegate"
  },
  "title" : "UITextViewDelegate"
}
-->

# UITextViewDelegate

The methods for receiving editing-related messages for text view objects.

```
@MainActor protocol UITextViewDelegate : UIScrollViewDelegate
```

## Overview

All of the methods in this protocol are optional. You can use them in situations where you might want to adjust the text a user is editing (such as in the case of a spell-checker program) or to modify the intended insertion point.

## Topics

### Responding to editing notifications

[`-  textViewShouldBeginEditing:`](/documentation/UIKit/UITextViewDelegate/textViewShouldBeginEditing(_:))

Asks the delegate whether to begin editing in the specified text view.

[`-  textViewDidBeginEditing:`](/documentation/UIKit/UITextViewDelegate/textViewDidBeginEditing(_:))

Tells the delegate when editing of the specified text view begins.

[`-  textViewShouldEndEditing:`](/documentation/UIKit/UITextViewDelegate/textViewShouldEndEditing(_:))

Asks the delegate whether to stop editing in the specified text view.

[`-  textViewDidEndEditing:`](/documentation/UIKit/UITextViewDelegate/textViewDidEndEditing(_:))

Tells the delegate when editing of the specified text view ends.

### Responding to text changes

[`-  textView:shouldChangeTextInRange:replacementText:`](/documentation/UIKit/UITextViewDelegate/textView(_:shouldChangeTextIn:replacementText:))

Asks the delegate whether to replace the specified text in the text view.

[`-  textViewDidChange:`](/documentation/UIKit/UITextViewDelegate/textViewDidChange(_:))

Tells the delegate when the user changes the text or attributes in the specified text view.

### Responding to selection changes

[`-  textViewDidChangeSelection:`](/documentation/UIKit/UITextViewDelegate/textViewDidChangeSelection(_:))

Tells the delegate when the text selection changes in the specified text view.

### Interacting with text data

[`-  textView:menuConfigurationForTextItem:defaultMenu:`](/documentation/UIKit/UITextViewDelegate/textView(_:menuConfigurationFor:defaultMenu:))

Asks the delegate for the menu configuration to be performed when interacting with a text item.

[`-  textView:primaryActionForTextItem:defaultAction:`](/documentation/UIKit/UITextViewDelegate/textView(_:primaryActionFor:defaultAction:))

Asks the delegate for the action to be performed when interacting with a text item. If a nil action is provided, the text view
will request a menu to be presented on primary action if possible.

[`-  textView:textItemMenuWillDisplayForTextItem:animator:`](/documentation/UIKit/UITextViewDelegate/textView(_:textItemMenuWillDisplayFor:animator:))

Informs the delegate that a text item menu is about to be presented with the specified animator.

[`-  textView:textItemMenuWillEndForTextItem:animator:`](/documentation/UIKit/UITextViewDelegate/textView(_:textItemMenuWillEndFor:animator:))

Informs the delegate that a text item menu is about to be dismissed with the specified animator.

### Providing a context menu

[`-  textView:editMenuForTextInRange:suggestedActions:`](/documentation/UIKit/UITextViewDelegate/textView(_:editMenuForTextIn:suggestedActions:))

Asks the delegate for the menu to display in the text view, based on the text range and actions the system provides.

### Customizing an edit menu

[`-  textView:willDismissEditMenuWithAnimator:`](/documentation/UIKit/UITextViewDelegate/textView(_:willDismissEditMenuWith:))

[`-  textView:willPresentEditMenuWithAnimator:`](/documentation/UIKit/UITextViewDelegate/textView(_:willPresentEditMenuWith:))

### Responding to writing tools interactions

[`-  textViewWritingToolsWillBegin:`](/documentation/UIKit/UITextViewDelegate/textViewWritingToolsWillBegin(_:))

Tells the delegate that an interaction with the writing tools interface is about to begin.

[`-  textViewWritingToolsDidEnd:`](/documentation/UIKit/UITextViewDelegate/textViewWritingToolsDidEnd(_:))

Tells the delegate that the current writing tools session ended.

[`-  textView:writingToolsIgnoredRangesInEnclosingRange:`](/documentation/UIKit/UITextViewDelegate/textView(_:writingToolsIgnoredRangesInEnclosingRange:))

Asks the delegate to specify any ranges of text you want the writing tools to ignore.

### Inserting a Smart Reply suggestion

[`-  textView:insertInputSuggestion:`](/documentation/UIKit/UITextViewDelegate/textView(_:insertInputSuggestion:))

Tells the delegate when the keyboard delivers an input suggestion.

### Deprecated

[`-  textView:shouldInteractWithTextAttachment:inRange:interaction:`](/documentation/UIKit/UITextViewDelegate/textView(_:shouldInteractWith:in:interaction:)-5qha9)

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

[`-  textView:shouldInteractWithURL:inRange:interaction:`](/documentation/UIKit/UITextViewDelegate/textView(_:shouldInteractWith:in:interaction:)-622ub)

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.

[`-  textView:shouldInteractWithTextAttachment:inRange:`](/documentation/UIKit/UITextViewDelegate/textView(_:shouldInteractWith:in:)-97zx6)

Asks the delegate whether the specified text view allows user interaction with the provided text attachment in the specified range of text.

[`-  textView:shouldInteractWithURL:inRange:`](/documentation/UIKit/UITextViewDelegate/textView(_:shouldInteractWith:in:)-98tho)

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

[`UITextItemInteraction`](/documentation/UIKit/UITextItemInteraction)

Constants that indicate the type of interaction the user expects to have with a URL or text attachment.

## Relationships

### Inherits From

[`UIScrollViewDelegate`](/documentation/UIKit/UIScrollViewDelegate)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

---

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)