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

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

```
optional func textView(_ textView: UITextView, primaryActionFor textItem: UITextItem, defaultAction: UIAction) -> UIAction?
```

## Parameters

`textView`

The text view requesting the primary action.

`textItem`

The text item for performing said action.

`defaultAction`

The default action for the text item. Return this to perform the default action.

## Return Value

Return a UIAction to be performed when the text item is interacted with. Return @c nil to prevent the action from being performed.

---

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)