iphone - 显示搜索结果 TableView 时隐藏 UITableView

标签 iphone ios objective-c xcode xcode4.2

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

tableView.backgroundColor = [UIColor clearColor];

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

当我在搜索字段中输入文本时,搜索结果显示正常,但由于结果表的背景是透明的,我看到了我的 tableviewtableview 显示搜索结果表。我想在 searchField 开始编辑时隐藏 tableView。我试过了

-(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。如何解决?

最佳答案

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

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

谢谢 :)

关于iphone - 显示搜索结果 TableView 时隐藏 UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14807406/

相关文章:

iphone - NSMutableURLRequest 发送部分帖子正文

iphone - 在哪里设置背景色?

ios - 如何在 Objective-C 中使自定义类线程安全

ios - UITableView 重新加载数据不起作用

ios - 有没有办法将 UIView 嵌入 UIScrollview 而不会丢失 iOS 中的 subview 约束?

ios - NSProgress fractionCompleted 键值观察方法未调用

python - 有没有办法用 python 开发 OS X 应用程序?

iphone - 如何在 iOS 中下载大文件?

iphone - 使用 Flash iOS 开发连接到互联网

ios - 无法访问我覆盖的单元格类