3

Given a UITableViewController with a UISearchBar, how does one change the 'No Results' text that appears in the table view (after any characters are entered) to something like 'Search by Name'? The reason is that the search in question is performed remotely (and has about a second delay), so I can only perform the search when the user selects the search button (not in response to changes to the search criteria). Thus, I still want the 'No Results' text to appear, but only if the user taps the 'Search' button and no results are returned from the server. I am currently have:

- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchScope:(NSInteger)searchOption
{
    return NO;
}

- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
    return NO;
}

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
    self.results = [Projects findAllRemote];
    [self.searchDisplayController.searchResultsTableView reloadData];
}
Kevin Sylvestre
  • 37,288
  • 33
  • 152
  • 232

1 Answers1

12

From Apple Support Forum: There isn't currently a supported way to change the text (good chance to file a bug!), but you can prevent it from showing up by returning a single row with a blank cell from your data source when you're still waiting for the user to press the search button. As long as there's a cell we won't show the no results text.

Kevin Sylvestre
  • 37,288
  • 33
  • 152
  • 232