UITableView Change message "No results"

Given the UITableViewController with the UISearchBar, how do you change the text "No results" that appears in the table view (after entering any characters) 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 search when the user selects the search button (not in response to changes in the search criteria). Thus, I still want the text β€œNo Results” to appear, but only if the user clicks the Search button and the results are not returned from the server. I 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]; } 
+3
source share
1 answer

From the Apple support forum: there is currently no way to change the text (a good chance to file an error!), But you can prevent it from appearing by returning one row with an empty cell from your data when you still expect the user to click the search button. As long as there is a cell, we will not show the text without results.

+12
source

All Articles