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

# textViewShouldEndEditing(_:)

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

```
optional func textViewShouldEndEditing(_ textView: UITextView) -> Bool
```

## Parameters

`textView`

The text view for which editing is about to end.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if editing should stop; otherwise, <doc://com.apple.documentation/documentation/Swift/false> if the editing session should continue

## Discussion

This method is called when the text view is asked to resign the first responder status. This might occur when the user tries to change the editing focus to another control. Before the focus actually changes, however, the text view calls this method to give your delegate a chance to decide whether it should.

Normally, you would return <doc://com.apple.documentation/documentation/Swift/true> from this method to allow the text view to resign the first responder status. You might return <doc://com.apple.documentation/documentation/Swift/false>, however, in cases where your delegate wants to validate the contents of the text view. By returning <doc://com.apple.documentation/documentation/Swift/false>, you could prevent the user from switching to another control until the text view contained a valid value.

Be aware that this method provides only a recommendation about whether editing should end. Even if you return <doc://com.apple.documentation/documentation/Swift/false> from this method, it is possible that editing might still end. For example, this might happen when the text view is forced to resign the first responder status by being removed from its parent view or window.

Implementation of this method by the delegate is optional. If it is not present, the first responder status is resigned as if this method had returned <doc://com.apple.documentation/documentation/Swift/true>.

---

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)