searchDisplayController

searchDisplayController

我有一个带有searchDisplayController的UISearchbar,可以通过IB拖动到我的表视图中。我的搜索范围栏不在搜索模式时隐藏。当我开始搜索时,范围栏将显示如下图所示

然后输入文本并搜索结果,当我滚动结果scopeBar时显示

因此,滚动时我应该怎么做才能显示范围栏?

这是我的代码:

- (void)searchDisplayControllerDidBeginSearch:(UISearchDisplayController *)controller {
    controller.searchResultsTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    controller.searchResultsTableView.bounces = NO;
}

- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar {
    self.searchDisplayController.searchBar.showsScopeBar =YES;
    [self.searchDisplayController.searchBar sizeToFit];
    [self.searchDisplayController.searchBar setShowsCancelButton:YES animated:YES];
    return YES;
}

最佳答案

我发现我的问题

- (BOOL)searchBarShouldEndEditing:(UISearchBar *)searchBar

我设置
self.searchDisplayController.searchBar.showsScopeBar

到NO。因此,当我滚动tableview时,此方法调用并隐藏范围栏

07-28 02:37
查看更多