---
title: UIContextMenuInteraction
framework: uikit
role: symbol
role_heading: Class
path: uikit/uicontextmenuinteraction
---

# UIContextMenuInteraction

An interaction object that you use to display relevant actions for your content.

## Declaration

```swift
@MainActor class UIContextMenuInteraction
```

## Mentioned in

Building a desktop-class iPad app

## Overview

Overview Use a UIContextMenuInteraction object to focus the user’s attention on a specific portion of your content, and to provide actions for the user to perform on that content. A context menu interaction object tracks Force Touch gestures on devices that support 3D Touch, and long-press gestures on devices that don’t support it. When the appropriate gesture occurs, this object animates your content to a new interface and displays the contextual menu that you supplied. UIKit manages all menu-related interactions and reports the selected action, if any, back to your app. A context menu interaction object inherits from UIInteraction. After creating the object, assign an appropriate object to its delegate property and use the addInteraction(_:) method to attach it to one of your views. The delegate object you provide must adopt the UIContextMenuInteractionDelegate protocol. Use the methods of that object to provide the contents of the contextual menu. Add your context menu interaction object to a view in your interface using the view’s addInteraction(_:) method.

## Topics

### Creating a context menu interaction object

- [init(delegate:)](uikit/uicontextmenuinteraction/init(delegate:).md)
- [Adding context menus in your app](uikit/adding-context-menus-in-your-app.md)
- [Adding menus and shortcuts to the menu bar and user interface](uikit/adding-menus-and-shortcuts-to-the-menu-bar-and-user-interface.md)

### Previewing and managing the content

- [delegate](uikit/uicontextmenuinteraction/delegate.md)
- [UIContextMenuInteractionDelegate](uikit/uicontextmenuinteractiondelegate.md)

### Getting the interaction’s location

- [location(in:)](uikit/uicontextmenuinteraction/location(in:).md)

### Getting the menu appearance

- [menuAppearance](uikit/uicontextmenuinteraction/menuappearance.md)
- [UIContextMenuInteraction.appearance](uikit/uicontextmenuinteraction/appearance.md)

### Managing menu interactions

- [dismissMenu()](uikit/uicontextmenuinteraction/dismissmenu().md)
- [updateVisibleMenu(_:)](uikit/uicontextmenuinteraction/updatevisiblemenu(_:).md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [Sendable](swift/sendable.md)
- [UIInteraction](uikit/uiinteraction.md)

## See Also

### Contextual menus

- [UIContextMenuSystem](uikit/uicontextmenusystem.md)
- [UIContextMenuInteractionDelegate](uikit/uicontextmenuinteractiondelegate.md)
- [UITargetedPreview](uikit/uitargetedpreview.md)
- [UIPreviewTarget](uikit/uipreviewtarget.md)
- [UIPreviewParameters](uikit/uipreviewparameters.md)
