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

# UIFindInteraction

An interaction that provides text finding and replacing operations using a system find panel.

```
@MainActor class UIFindInteraction
```

## Overview

Use a find interaction to add text-finding capabilities to your view.

When invoking the interaction, the system displays a find panel for entering a string to search, with buttons for navigating between results. When supporting replacement, this also includes a field for the text replacing matches. The find panel presents as a part of the onscreen keyboard when visible, or inline as part of the receiver’s view hierarchy.

Input from a hardware keyboard triggers a find interaction using standard system shortcuts such as Command+F for find, Command+G for find next, and Command+Shift+G for find previous. Adding the interaction also enables these commands in the menu bar on macOS when your view becomes first responder. You can also trigger the interaction by calling the [`presentFindNavigator(showingReplace:)`](/documentation/UIKit/UIFindInteraction/presentFindNavigator(showingReplace:)) method on the interaction object, providing access to find and replace operations programatically.

Some classes, such as [`UITextView`](/documentation/UIKit/UITextView), <doc://com.apple.documentation/documentation/WebKit/WKWebView>, and <doc://com.apple.documentation/documentation/PDFKit/PDFView>, support built-in find interactions. To enable the interaction on these views, set [`isFindInteractionEnabled`](/documentation/UIKit/UITextView/isFindInteractionEnabled) to `true`.

```swift
textView.isFindInteractionEnabled = true
```

To add find and replace operations to other views:

1. Create the find interaction object, passing a delegate into the default initializer.
2. Add the interaction by calling the [`addInteraction(_:)`](/documentation/UIKit/UIView/addInteraction(_:)) method on the view.
3. Provide a [`UIFindSession`](/documentation/UIKit/UIFindSession) object to manage the search performed on the content displayed in the view. You return this object through the [`findInteraction(_:sessionFor:)`](/documentation/UIKit/UIFindInteractionDelegate/findInteraction(_:sessionFor:)) method on the delegate.

The following example creates a find interaction for a view that presents searchable content for a document.

```swift
let document = Document(string: "")
lazy var interactionView = InteractionView(document: document)

lazy var findInteraction = UIFindInteraction(sessionDelegate: self)

override func viewDidLoad() {
    super.viewDidLoad()

    // Add the find interaction.
    interactionView.addInteraction(findInteraction)
}

func findInteraction(_ interaction: UIFindInteraction, sessionFor view: UIView) -> UIFindSession? {
    // Return a searchable object.
    return UITextSearchingFindSession(searchableObject: document)
}
```

Implement the [`UITextSearching`](/documentation/UIKit/UITextSearching-53wjq) protocol on the class that encapsulates the searchable content for your view to use an instance of [`UITextSearchingFindSession`](/documentation/UIKit/UITextSearchingFindSession) as the session object. Alternatively, you can subclass [`UIFindSession`](/documentation/UIKit/UIFindSession) when you want to manage the details of the session using a custom class.

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

## Topics

### Creating a find interaction

[`init(sessionDelegate:)`](/documentation/UIKit/UIFindInteraction/init(sessionDelegate:))

Initializes a find interaction object with the delegate object you specify.

### Managing find interactions

[`delegate`](/documentation/UIKit/UIFindInteraction/delegate)

An object that updates your app’s presentation and provides the session object for managing the interaction’s search.

[`presentFindNavigator(showingReplace:)`](/documentation/UIKit/UIFindInteraction/presentFindNavigator(showingReplace:))

Begins a search, displaying the find panel.

[`dismissFindNavigator()`](/documentation/UIKit/UIFindInteraction/dismissFindNavigator())

Dismisses the find panel, if present.

[`findNext()`](/documentation/UIKit/UIFindInteraction/findNext())

Highlights the next found result in the content, relative to the currently highlighted result.

[`findPrevious()`](/documentation/UIKit/UIFindInteraction/findPrevious())

Highlights the previously found result in the document, relative to the currently highlighted result.

### Configuring the find panel

[`isFindNavigatorVisible`](/documentation/UIKit/UIFindInteraction/isFindNavigatorVisible)

A Boolean value that indicates when the find panel displays onscreen.

[`searchText`](/documentation/UIKit/UIFindInteraction/searchText)

The search query with which to prepopulate the find panel’s search text field.

[`replacementText`](/documentation/UIKit/UIFindInteraction/replacementText)

The replacement string with which to prepopulate the find panel’s replace text field.

[`optionsMenuProvider`](/documentation/UIKit/UIFindInteraction/optionsMenuProvider)

A closure that populates the search options for a find interaction.

### Managing the search

[`activeFindSession`](/documentation/UIKit/UIFindInteraction/activeFindSession)

The object that manages the state, presentation, and behavior of an active search.

[`updateResultCount()`](/documentation/UIKit/UIFindInteraction/updateResultCount())

Updates the results the interface displays for the active search.

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



---

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)