tng
tng

Reputation: 4336

Perform search only when enter is pressed for UISearchController

I'm using UISearchController (not UISearchDisplayController) and I cannot figure out how to get the search to fire off only if the user hits enter in the text box. The UISearchResultsUpdating protocol only has a single method and it wasn't clear that any of the states there could be checked to accomplish the search only when enter is pressed.

Is this possible?

Upvotes: 2

Views: 656

Answers (1)

matt
matt

Reputation: 534987

If you don't want to do anything on each updateSearchResultsForSearchController call, don't do anything. Just set yourself as the search field's delegate (UISearchBarDelegate) and now you can respond "if the user hits enter in the text box" as the delegate (whatever it is you mean by that).

Upvotes: 1

Related Questions