<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "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(_:shouldChangeTextIn: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(_:menuConfigurationFor:defaultMenu:)`](/documentation/UIKit/UITextViewDelegate/textView(_:menuConfigurationFor:defaultMenu:))

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

[`textView(_:primaryActionFor: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(_:textItemMenuWillDisplayFor: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(_:textItemMenuWillEndFor: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(_:editMenuForTextIn: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(_:willDismissEditMenuWith:)`](/documentation/UIKit/UITextViewDelegate/textView(_:willDismissEditMenuWith:))

[`textView(_:willPresentEditMenuWith:)`](/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(_:shouldInteractWith:in: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(_:shouldInteractWith:in: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(_:shouldInteractWith:in:)`](/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(_:shouldInteractWith:in:)`](/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.



---

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)
