Search code examples
iosuisearchdisplaycontroller

How to get UISearchDisplayController to search only after search button is pressed


I am implementing search in my iOS app and so far I am using the shouldReloadTableForSearchString method to get the string from the search bar to execute the search. However I have noticed that the method calls whenever the string a user is entering changes. That's good to search through one's contacts but thats not what I'm using it for so I'm looking for a way to only start searching when the user has clicked search and entered their string not while their typing. How can I get that done?


Solution

  • Setup a delegate for the search bar and implement the searchBarSearchButtonClicked: method. Do your searching from that method. Just return NO from the shouldReloadTableForSearchString method.