<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "tvOS: -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UISearchBarDelegate",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(pl)UISearchBarDelegate"
  },
  "title" : "UISearchBarDelegate"
}
-->

# UISearchBarDelegate

A collection of optional methods that you implement to make a search bar control functional.

```
@MainActor protocol UISearchBarDelegate : UIBarPositioningDelegate
```

## Overview

A [`UISearchBar`](/documentation/UIKit/UISearchBar) object provides the user interface for a search field on a bar, but it’s the application’s responsibility to implement the actions when buttons are tapped. At a minimum, the delegate needs to perform the actual search when text is entered in the text field.

## Topics

### Managing the search text

[`searchBar(_:textDidChange:)`](/documentation/UIKit/UISearchBarDelegate/searchBar(_:textDidChange:))

Tells the delegate that the user changed the search text.

[`searchBar(_:shouldChangeTextIn:replacementText:)`](/documentation/UIKit/UISearchBarDelegate/searchBar(_:shouldChangeTextIn:replacementText:))

Ask the delegate if text in a specified range should be replaced with given text.

[`searchBarShouldBeginEditing(_:)`](/documentation/UIKit/UISearchBarDelegate/searchBarShouldBeginEditing(_:))

Asks the delegate if editing should begin in the specified search bar.

[`searchBarTextDidBeginEditing(_:)`](/documentation/UIKit/UISearchBarDelegate/searchBarTextDidBeginEditing(_:))

Tells the delegate when the user begins editing the search text.

[`searchBarShouldEndEditing(_:)`](/documentation/UIKit/UISearchBarDelegate/searchBarShouldEndEditing(_:))

Asks the delegate if editing should stop in the specified search bar.

[`searchBarTextDidEndEditing(_:)`](/documentation/UIKit/UISearchBarDelegate/searchBarTextDidEndEditing(_:))

Tells the delegate that the user finished editing the search text.

### Responding to clicks in search controls

[`searchBarBookmarkButtonClicked(_:)`](/documentation/UIKit/UISearchBarDelegate/searchBarBookmarkButtonClicked(_:))

Tells the delegate that the bookmark button was tapped.

[`searchBarCancelButtonClicked(_:)`](/documentation/UIKit/UISearchBarDelegate/searchBarCancelButtonClicked(_:))

Tells the delegate that the cancel button was tapped.

[`searchBarSearchButtonClicked(_:)`](/documentation/UIKit/UISearchBarDelegate/searchBarSearchButtonClicked(_:))

Tells the delegate that the search button was tapped.

[`searchBarResultsListButtonClicked(_:)`](/documentation/UIKit/UISearchBarDelegate/searchBarResultsListButtonClicked(_:))

Tells the delegate that the search results list button was tapped.

### Responding to scope button changes

[`searchBar(_:selectedScopeButtonIndexDidChange:)`](/documentation/UIKit/UISearchBarDelegate/searchBar(_:selectedScopeButtonIndexDidChange:))

Tells the delegate that the scope button selection changed.



---

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)