1

我要疯了!这是我的问题。我想显示UISearchBar.ScopeBar何时开始搜索并在搜索后隐藏它。我在 iPhone 中找到了一个解决方案帖子:从 searchBar 中隐藏 scopeBar, 但它对我不起作用。这是我的代码:

   self.friendSearchBar.scopeButtonTitles = [NSArray arrayWithObjects:@"Phone",@"Name", nil];
   self.friendSearchBar.selectedScopeButtonIndex = 0;
   self.friendSearchBar.showsScopeBar = YES;
4

1 回答 1

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;
}
于 2013-10-07T18:00:06.137 回答