UITableView更改“无结果”消息 [英] UITableView Change 'No Results' Message

查看:105
本文介绍了UITableView更改“无结果”消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定UITableViewController和UISearchBar,如何将表视图中出现的无结果文本(输入任何字符后)更改为按名称搜索等内容?原因是所讨论的搜索是远程执行的(并且具有大约第二延迟),因此当用户选择搜索按钮(不响应于搜索条件的改变)时,我只能执行搜索。因此,我仍然希望无结果文本显示,但只有当用户点击搜索按钮,并且没有从服务器返回结果。我目前有:

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];
}


推荐答案

目前不是一种支持的方式来更改文本(很有可能提交错误!),但是您可以防止它通过返回一个空白单元格行从您的数据源,当你还在等待用户按搜索按钮。只要有一个单元格,我们就不会显示没有结果的文本。

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.

这篇关于UITableView更改“无结果”消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆