<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIEditMenuInteraction",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIEditMenuInteraction"
  },
  "title" : "UIEditMenuInteraction"
}
-->

# UIEditMenuInteraction

An interaction that provides edit operations using a menu.

```
@MainActor class UIEditMenuInteraction
```

## Overview

Edit menu interactions provide actions, such as cut, copy, and paste, for the content a view displays. The interaction chooses its presentation style based on the input method. For touch interactions, the system presents the actions in an edit menu that displays a compact, horizontal list. For a secondary click on devices with pointer-based input, the system presents them in a context menu.

Standard UIKit classes, such as [`UITextView`](/documentation/UIKit/UITextView) and [`UITextField`](/documentation/UIKit/UITextField), are preconfigured to use edit menu interactions.

To add an edit menu interaction to a generic view, create the interaction and pass an optional delegate to the default initializer, add it to your view with [`addInteraction(_:)`](/documentation/UIKit/UIView/addInteraction(_:)), and add a gesture recognizer whose action calls [`presentEditMenu(with:)`](/documentation/UIKit/UIEditMenuInteraction/presentEditMenu(with:)). The following example presents the menu when a long press begins.

```swift
override func viewDidLoad() {
    super.viewDidLoad()

    // Add the edit menu interaction.
    let interaction = UIEditMenuInteraction(delegate: self)
    editMenuInteraction = interaction
    interactionView.addInteraction(interaction)

    // Create the gesture recognizer.
    let longPress = UILongPressGestureRecognizer(target: self, action: #selector(didLongPress(_:)))
    longPress.allowedTouchTypes = [UITouch.TouchType.direct.rawValue as NSNumber]
    interactionView.addGestureRecognizer(longPress)
}

@objc func didLongPress(_ recognizer: UIGestureRecognizer) {
    // Present the menu once, when the long press begins.
    guard recognizer.state == .began else { return }

    // Use the coordinate space of the view that has the interaction.
    let location = recognizer.location(in: interactionView)
    let configuration = UIEditMenuConfiguration(identifier: nil, sourcePoint: location)

    // Present the edit menu interaction.
    editMenuInteraction?.presentEditMenu(with: configuration)
}
```

Gesture recognizers support touch input like the long-press gesture in the example above. When someone performs a secondary click on a device with pointer-based input, the interaction presents the menu automatically.

By default, an edit menu interaction generates a menu that includes commands for the standard edit actions your view implements. For details about these actions, see [`UIResponderStandardEditActions`](/documentation/UIKit/UIResponderStandardEditActions). Use the methods in the [`UIEditMenuInteractionDelegate`](/documentation/UIKit/UIEditMenuInteractionDelegate) protocol to add items to the menu and to set the rectangle the menu points to. For text views, specify the items the menu displays for specific text ranges by using methods from the [`UITextViewDelegate`](/documentation/UIKit/UITextViewDelegate), [`UITextFieldDelegate`](/documentation/UIKit/UITextFieldDelegate), or [`UITextInput`](/documentation/UIKit/UITextInput) protocols.

## Share code with Mac Catalyst

In iOS and iPadOS, an edit menu interaction can present a menu in two ways. Calling [`presentEditMenu(with:)`](/documentation/UIKit/UIEditMenuInteraction/presentEditMenu(with:)) presents an edit menu, and a secondary click presents a context menu. Mac Catalyst doesn’t have the edit menu presentation, so [`presentEditMenu(with:)`](/documentation/UIKit/UIEditMenuInteraction/presentEditMenu(with:)) has no effect there, and a secondary click is the only way to present a menu.

Because the interaction asks the same delegate method for the menu, keep the [`presentEditMenu(with:)`](/documentation/UIKit/UIEditMenuInteraction/presentEditMenu(with:)) call in shared code and implement [`editMenuInteraction(_:menuFor:suggestedActions:)`](/documentation/UIKit/UIEditMenuInteractionDelegate/editMenuInteraction(_:menuFor:suggestedActions:)) once.

> Related Sessions from WWDC22:
> Session 10071: [Adopt desktop-class editing interactions](https://developer.apple.com/wwdc22/10071)

## Topics

### Creating an edit menu interaction

[`init(delegate: (any UIEditMenuInteractionDelegate)?)`](/documentation/UIKit/UIEditMenuInteraction/init(delegate:))

Initializes an edit menu interaction object with the delegate object you specify.

### Responding to menu requests

[`var delegate: (any UIEditMenuInteractionDelegate)?`](/documentation/UIKit/UIEditMenuInteraction/delegate)

An object that customizes presentation of the menu and actions to display for an edit menu interaction.

[`protocol UIEditMenuInteractionDelegate`](/documentation/UIKit/UIEditMenuInteractionDelegate)

The methods for customizing the menu the interaction displays.

### Managing edit menu interactions

[`func presentEditMenu(with: UIEditMenuConfiguration)`](/documentation/UIKit/UIEditMenuInteraction/presentEditMenu(with:))

Presents an edit menu using the object you provide for configuration.

[`func reloadVisibleMenu()`](/documentation/UIKit/UIEditMenuInteraction/reloadVisibleMenu())

Updates the actions an edit menu displays.

[`func updateVisibleMenuPosition(animated: Bool)`](/documentation/UIKit/UIEditMenuInteraction/updateVisibleMenuPosition(animated:))

Updates the position of the currently visible menu with an option to animate the action.

[`func dismissMenu()`](/documentation/UIKit/UIEditMenuInteraction/dismissMenu())

Dismiss the edit menu if present.

[`func location(in: UIView?) -> CGPoint`](/documentation/UIKit/UIEditMenuInteraction/location(in:))

Returns the location of the user interaction in the specified view’s coordinate system.

## See Also

[Building a desktop-class iPad app](/documentation/UIKit/building-a-desktop-class-ipad-app)

Optimize your iPad app’s user experience by adopting desktop-class enhancements for multitasking with Stage Manager, document interactions, text editing, search, and more.

## Relationships

### Conforms To

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

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

[`CVarArg`](/documentation/Swift/CVarArg)

[`Sendable`](/documentation/Swift/Sendable)

[`Hashable`](/documentation/Swift/Hashable)

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

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)