UISearchDisplayController没有结果tableView? [英] UISearchDisplayController with no results tableView?

查看:133
本文介绍了UISearchDisplayController没有结果tableView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,UISearchDisplayController在激活时会使tableView变暗并聚焦searchBar。只要在searchBar中输入文本,它就会创建一个searchResultsTableView,它在searchBar和键盘之间显示。当第二个UITableView被加载/显示/隐藏/卸载时,将调用searchDisplayController的委托。通常它会在输入时显示实时搜索结果或自动完成条目。



在我的应用中,我想搜索网络服务,我不想为每个字母调用网络服务用户输入。因此,我想完全禁用searchResultsTableView并在输入文本时保持灰色的黑色叠加。然后,一旦他点击搜索按钮,我就会触发搜索(带有加载屏幕)。



为searchResultsTableView返回零行看起来不太好,因为它显示的是使用无结果消息清空searchResultsTableView。我试图在它出现时隐藏表( searchDisplayController:didLoadSearchResultsTableView:),但是黑色的灰色覆盖也是隐藏的,这样底层的tableView就会再次完全可见。 / p>

除了从头开始重新创建UISearchDisplayController功能之外的任何想法吗?

解决方案

这里是一个小技巧,我只想出
,你也必须在编辑searchstring时返回0结果

   - ( BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString 
{
savedSearchTerm = searchString;

[controller.searchResultsTableView setBackgroundColor:[UIColor colorWithWhite:0.0 alpha:0.8]];
[controller.searchResultsTableView setRowHeight:800];
[controller.searchResultsTableView setScrollEnabled:NO];
返回NO;
}

- (void)searchDisplayController:(UISearchDisplayController *)controller didHideSearchResultsTableView:(UITableView *)tableView
{
//撤消上面的更改以防止报告人工制品下面是mclin
}

我想你会想出下一步该做什么


Usually, a UISearchDisplayController, when activated, dims the tableView and focuses the searchBar. As soon as you enter text into the searchBar, it creates a searchResultsTableView that displays between the searchBar and the keyboard. The searchDisplayController's delegate gets called when this second UITableView is loaded/shown/hidden/unloaded. Usually it shows live search results or autocompletion entries while typing.

In my app, I want to search a webservice and I don't want to call the webservice for each letter the user enters. Therefore, I want to entirely disable the searchResultsTableView and keep the dimmed black overlay while he enters text. I would then trigger the search (with a loading screen) once he hits the search button.

Just returning zero rows for the searchResultsTableView doesn't look nice since it displays an empty searchResultsTableView with a "no results" message. I tried to hide the table when it appears (searchDisplayController:didLoadSearchResultsTableView:) which works, but the blacked dimmed overlay is also hidden so that the underlying tableView is completely visible again.

Any ideas besides recreating the UISearchDisplayController functionality from scratch?

解决方案

here is a little trick that i just figured out and also you have to return 0 results while editing searchstring

- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
    savedSearchTerm = searchString;

    [controller.searchResultsTableView setBackgroundColor:[UIColor colorWithWhite:0.0 alpha:0.8]];
    [controller.searchResultsTableView setRowHeight:800];
    [controller.searchResultsTableView setScrollEnabled:NO];
    return NO;
}

- (void)searchDisplayController:(UISearchDisplayController *)controller didHideSearchResultsTableView:(UITableView *)tableView
{
    // undo the changes above to prevent artefacts reported below by mclin
}

i think you'll figure out what to do next

这篇关于UISearchDisplayController没有结果tableView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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