我想让搜索显示 Controller 以这种方式工作:
当用户按下搜索字段时,它会上升到顶部并显示键盘。通常情况下会发生这种情况,但当用户键入内容时会显示表格 View 。
我不想在用户输入时做任何事情,当他按下 Search
时,我会这样做:
[_searchController setActive:NO animated:YES];
并在我的自定义创建 TableView 中加载数据。
我怎样才能实现这种功能。
编辑。 我找到了一些解决方案:
- (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;
}
也许有人有更好的方法?
最佳答案
您可以设置searchResultsTableView
的hidden
属性
controller.searchResultsTableView.hidden = YES;
每当你想要它回来时,只需将 hidden
设置为 NO 并将它带到前面,以防它已经显示
controller.searchResultsTableView.hidden = NO;
[controller.searchResultsTableView.superview bringSubviewToFront:controller.searchResultsTableView];
关于objective-c - 隐藏搜索显示 Controller 的 TableView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12005903/