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

# UISearchDisplayController

An object that manages the display of a search bar, along with a table view that displays search results.

```
@MainActor class UISearchDisplayController
```

## Overview

You initialize a search display controller with a search bar and a view controller responsible for managing the data to be searched. When the user starts a search, the search display controller superimposes the search interface over the original view controller’s view and shows the search results in its table view.

In addition to managing the searchable data, the original view controller typically plays four more roles you need to fill when using a search display controller. Those roles are the following:

1. Data source for the search results table view ([`searchResultsDataSource`](/documentation/UIKit/UISearchDisplayController/searchResultsDataSource)), which provides the data for the results table.
2. Delegate for the search results table view ([`searchResultsDelegate`](/documentation/UIKit/UISearchDisplayController/searchResultsDelegate)), which responds to the user’s selection of an item in the results table.
3. Delegate for the search display controller ([`delegate`](/documentation/UIKit/UISearchDisplayController/delegate)), which responds to events such the starting or ending of a search, and the showing or hiding of the search interface. As a convenience, this delegate may also be told about changes to the search string or search scope, so that the results table view can be reloaded.
4. Delegate for the search bar ([`delegate`](/documentation/UIKit/UISearchBar/delegate) described in [`UISearchBar`](/documentation/UIKit/UISearchBar)), which responds to changes in search criteria.

Typically, you initialize a search display controller from a view controller (usually an instance of [`UITableViewController`](/documentation/UIKit/UITableViewController)) that’s displaying a list. See the Simple UISearchBar with State Restoration sample code project for an example of how to configure a search display controller in Interface Builder. To perform configuration programmatically, set `self` for the search display controller’s view controller and search results data source and delegate, as shown here:

```objc
searchController = [[UISearchDisplayController alloc]
                         initWithSearchBar:searchBar contentsController:self];
searchController.delegate = self;
searchController.searchResultsDataSource = self;
searchController.searchResultsDelegate = self;
```

If you follow this pattern, then in the table view data source and delegate methods you can check the methods’ table view argument to determine which table view is sending the message:

```objc
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
 
    if (tableView == self.tableView) {
        return ...;
    }
    // If necessary (if self is the data source for other table views),
    // check whether tableView is searchController.searchResultsTableView.
    return ...;
}
```

> Important:
> A view controller or search bar can be associated with only a single search display controller at a time. If a search display controller is destroyed (for example, in response to a memory warning), then you can create a new one and associate it with the original view controller or search bar.

Starting in iOS 7.0, you can use a search display controller with a navigation bar (an instance of the [`UINavigationBar`](/documentation/UIKit/UINavigationBar) class) by configuring the search display controller’s [`displaysSearchBarInNavigationBar`](/documentation/UIKit/UISearchDisplayController/displaysSearchBarInNavigationBar) and [`navigationItem`](/documentation/UIKit/UISearchDisplayController/navigationItem) properties.

## Topics

### Initializing a search bar

[`-  initWithSearchBar:contentsController:`](/documentation/UIKit/UISearchDisplayController/init(searchBar:contentsController:))

Returns a display controller initialized with the given search bar and contents controller.

### Displaying the search Interface

[`active`](/documentation/UIKit/UISearchDisplayController/isActive)

The visibility state of the search interface.

[`-  setActive:animated:`](/documentation/UIKit/UISearchDisplayController/setActive(_:animated:))

Displays or hides the search interface, optionally with animation.

### Configuring a search bar

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

The controller’s delegate.

[`searchBar`](/documentation/UIKit/UISearchDisplayController/searchBar)

The search bar.

[`searchContentsController`](/documentation/UIKit/UISearchDisplayController/searchContentsController)

The view controller that manages the contents being searched.

[`searchResultsTableView`](/documentation/UIKit/UISearchDisplayController/searchResultsTableView)

The table view in which the search results are displayed.

[`searchResultsDataSource`](/documentation/UIKit/UISearchDisplayController/searchResultsDataSource)

The data source for the table view in which the search results are displayed.

[`searchResultsDelegate`](/documentation/UIKit/UISearchDisplayController/searchResultsDelegate)

The delegate for the table view in which the search results are displayed.

[`searchResultsTitle`](/documentation/UIKit/UISearchDisplayController/searchResultsTitle)

The title for the search results view.

[`displaysSearchBarInNavigationBar`](/documentation/UIKit/UISearchDisplayController/displaysSearchBarInNavigationBar)

Specifies that the navigation bar contains a search bar.

[`navigationItem`](/documentation/UIKit/UISearchDisplayController/navigationItem)

Represents the search display controller in a navigation controller’s navigation bar.

## Relationships

### Inherits From

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

### Conforms To

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

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

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

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

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

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

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

---

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)