开发者

UITableView Change 'No Results' Message

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)searchDisplayControl开发者_如何学Cler:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
    return NO;
}

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
    self.results = [Projects findAllRemote];
    [self.searchDisplayController.searchResultsTableView reloadData];
}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜