Protocol

UISearchBarDelegate

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

Overview

A 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

Editing Text

func searchBar(UISearchBar, textDidChange: String)

Tells the delegate that the user changed the search text.

func searchBar(UISearchBar, shouldChangeTextIn: NSRange, replacementText: String)

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

func searchBarShouldBeginEditing(UISearchBar)

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

func searchBarTextDidBeginEditing(UISearchBar)

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

func searchBarShouldEndEditing(UISearchBar)

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

func searchBarTextDidEndEditing(UISearchBar)

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

Clicking Buttons

func searchBarBookmarkButtonClicked(UISearchBar)

Tells the delegate that the bookmark button was tapped.

func searchBarCancelButtonClicked(UISearchBar)

Tells the delegate that the cancel button was tapped.

func searchBarSearchButtonClicked(UISearchBar)

Tells the delegate that the search button was tapped.

func searchBarResultsListButtonClicked(UISearchBar)

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

Scope Button

func searchBar(UISearchBar, selectedScopeButtonIndexDidChange: Int)

Tells the delegate that the scope button selection changed.

Relationships

See Also

Search Interface

class UISearchContainerViewController

A wrapper for search results that you want to embed in a container view controller.

class UISearchBar

A text field–like control that supports text-based searches.

class UISearchController

An object that manages the display of search results based on interactions with a search bar.

protocol UISearchResultsUpdating

A set of methods that let you update search results based on information the user enters into the search bar.