显示searchResultsTableView时隐藏UITableView [英] Hide UITableView when searchResultsTableView displayed

查看:42
本文介绍了显示searchResultsTableView时隐藏UITableView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个实现了 searchDisplayController UITableView .我有

I have a UITableView with a searchDisplayController implemented. I have

tableView.backgroundColor = [UIColor clearColor];

self.searchDisplayController.searchResultsTableview.backgroundColor = [UIColor clearColor];

当我在搜索字段中输入文本时,搜索结果显示良好,但是由于结果表的背景是透明的,因此我看到了 tableview tableview 显示搜索结果表.我想在searchField开始编辑时隐藏 tableView .我尝试过

When I enter text in the search field, the search results are displaying fine, but as the background of the resultant table is transparent, I am seeing my tableview and on the tableview the search result table is displayed. I want to hide the tableView when the searchField began editing. I have tried

-(BOOL)searchDisplayController:(UISearchDisplayController *)controller 
shouldReloadTableForSearchString:(NSString *)searchString
{
    [tableView setHidden:YES];
    [self filterContentForSearchText:searchString 
                               scope:[[self.searchDisplayController.searchBar scopeButtonTitles]
                                      objectAtIndex:[self.searchDisplayController.searchBar
                                                     selectedScopeButtonIndex]]];

    return YES;
}

但是它用tableView隐藏了searchBar.如何解决?

But it hides the searchBar with the tableView. How to fix it?

推荐答案

首先,我知道您在 UITableView 上添加了 searchDisplayController .

First i know that you add searchDisplayController on UITableView.

请删除它,并在 View Controller 上而不是 UITableView 上添加 UISearchDisplayController ,因为如果您隐藏了 UITableView 然后 UISearchDisplayController 也将隐藏,因为您在 UITableView 上添加了UISearchDisplayController.

Remove it Please and Add your UISearchDisplayController on your View Controller not on UITableView, beacuse if you hide UITableView then UISearchDisplayController also hide because you added UISearchDisplayController on UITableView.

谢谢:)

这篇关于显示searchResultsTableView时隐藏UITableView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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