Search code examples
iphoneuisearchbaruisearchdisplaycontrolleruisearchbardelegate

Search Display to not show results until search bar is tapped


I think I may be missing something obvious:

Is there a simple way to modify the UISearchBar or UISearchDisplayController so that it doesn't reload the view after each letter typed but only after the Search button is hit?


Solution

  • I figured it out. Most of the examples I found search the text here:

    - (void)searchBar:(UISearchBar *)theSearchBar textDidChange:(NSString *)searchText
    

    but I just didn't implement that method and instead just wrote my own search function which I called here:

    // called when keyboard search button pressed
    
    - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{
    
        [self fetchTheSearchString:searchBar.text];
        [searchBar resignFirstResponder];
        [self.tableView reloadData];
    
    }