我要疯了!这是我的问题。我想在搜索后开始搜索并隐藏它时显示UISearchBar.ScopeBar
。我找到了一个解决方案帖子
iPhone : hide a scopeBar from a searchBar
但它对我不起作用。
这是我的代码:
self.friendSearchBar.scopeButtonTitles = [NSArray arrayWithObjects:@"Phone",@"Name", nil];
self.friendSearchBar.selectedScopeButtonIndex = 0;
self.friendSearchBar.showsScopeBar = YES;
答案 0 :(得分:0)
您好,搜索栏在搜索后消失,您需要实现此功能。
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
{
YourScopeGoesHere scopeKey = controller.searchBar.selectedScopeButtonIndex;
[self searchForText:searchString scope:scopeKey];
return YES;
}
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchScope:(NSInteger)searchOption
{
NSString *searchString = controller.searchBar.text;
[self searchForText:searchString scope:searchOption];
return YES;
}