Frank
Frank

Reputation: 155

initial selected searchbar

I have a UISearchBar from a Search Display Controller and want the UISearchBar to be selected when the view is Loaded.

Can anyone tell me how this can be done?

Upvotes: 2

Views: 593

Answers (2)

Matt Bierner
Matt Bierner

Reputation: 65613

Call the method becomeFirstResponder on the search bar.

[searchBar becomeFirstResponder] will programmatically select the search bar. See the UIResponder docs for more details on this.

Upvotes: 1

Felix
Felix

Reputation: 35394

Try

[searchBar becomeFirstResponder];

in your viewDidAppear method and when the user pushes the "search button", call

[searchBar resignFirstResponder];

and begin your search algorithm.

Upvotes: 2

Related Questions