Class

UISearchTextField

A view for displaying and editing text and search tokens.

Declaration

@interface UISearchTextField : UITextField

Overview

Use a search text field to display search criteria represented as text and tokens, and allow the user to edit that criteria. Tokens are discrete representations of nontextual content that your app can create and use to represent filters that limit the search results. Tokens always occur contiguously before any text in the search field.

UISearchBar hosts a search text field, but you may also use a search text field in other roles, such as the title view of a UINavigationItem.

Tokens can be programatically selected by including their position in a range assigned to the selectedTextRange property.

Topics

Converting Text into Tokens

- replaceTextualPortionOfRange:withToken:atIndex:

Converts text in a search field into a search token.

textualRange

The range of the field's text content.

Supporting Token Interactions

allowsDeletingTokens

A Boolean that indicates whether the user can remove tokens from the search field.

allowsCopyingTokens

A Boolean that indicates whether the user can copy or drag tokens from the search field.

delegate

The receiver’s delegate.

UISearchTextFieldDelegate

A method that supports cutting, copying, and dragging tokens from a search field.

UISearchTextFieldPasteItem

A protocol that supports pasting tokens.

Adding and Removing Tokens

tokens

The collection of tokens in the search text field.

- insertToken:atIndex:

Adds a search token at a specific index.

- removeTokenAtIndex:

Removes a particular search token from the search text field.

Customizing Token Behavior

tokenBackgroundColor

The background color for all tokens in the search text field.

- tokensInRange:

Returns the search field's tokens that are within a given range.

- positionOfTokenAtIndex:

Converts a token index into a text position.

Relationships

Inherits From

See Also

Text Views

UILabel

A view that displays one or more lines of informational text.

UITextField

An object that displays an editable text area in your interface.

UITextView

A scrollable, multiline text region.

UISearchToken

Search criteria in a search text field, represented by text and an optional icon.

UISearchTextFieldDelegate

A method that supports cutting, copying, and dragging tokens from a search field.

Drag and Drop Customization

Extend the standard drag and drop support for text views to include custom types of content.