UITableView更改'无结果'信息 [英] UITableView Change 'No Results' Message

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

问题描述

给出一个带有UISearchBar的UITableViewController,如何将在表格视图(输入任何字符后)中出现的无结果"文本更改为按名称搜索"?原因是有问题的搜索是远程执行的(大约有第二个延迟),因此我只能在用户选择搜索按钮时执行搜索(而不是响应于搜索标准的更改).因此,我仍然希望显示无结果"文本,但前提是用户点击搜索"按钮并且服务器没有返回结果.我目前有:

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

推荐答案

来自Apple支持论坛:目前尚不支持更改文本的方法(很好的机会来提交bug!),但是您可以防止它发生当您仍在等待用户按下搜索按钮时,通过从数据源返回一行带有空白单元格的行来显示.只要有一个单元格,我们就不会显示无结果文本.

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天全站免登陆