我想我在iOS 5.0中发现了一个关于UISearchBar和它的范围栏的错误。我最初在XIB中显示启用的范围栏。
在运行期间,示波器栏会正确显示。但是,当单击搜索文本字段并单击取消按钮时,范围栏将从屏幕中删除。屏幕区域仍然可见。见截图。
如果有人知道如何解决这个问题,请告诉我。
感谢。凯。
答案 0 :(得分:4)
尝试实施' searchBarShouldEndEditing'委托在搜索栏存在时重新启用范围栏。
- (BOOL)searchBarShouldEndEditing:(UISearchBar *)searchBar
{
self.searchBar.showsScopeBar = YES;
[self.searchBar sizeToFit];
self.tableView.tableHeaderView = self.searchBar;
return YES;
}
您可以详细了解此解决方案here
答案 1 :(得分:0)
请说明您的期望/想要发生的事情。有几种委托方法。以下是我在SearchBarViewController中做的一些事情:
首先,我让VC成为代表:
- (void)viewDidLoad {
searchBar.delegate = self;
}
关闭并返回呈现视图控制器(我的搜索框是模态的):
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
[[self presentingViewController] dismissModalViewControllerAnimated:YES];
}
过滤
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString {
[self filterContentForSearchText:searchString scope:
[[self.searchDisplayController.searchBar scopeButtonTitles] objectAtIndex:[self.searchDisplayController.searchBar selectedScopeButtonIndex]]];
// Return YES to cause the search result table view to be reloaded.
return YES;
}
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchScope:(NSInteger)searchOption {
[self filterContentForSearchText:[self.searchDisplayController.searchBar text] scope:
[[self.searchDisplayController.searchBar scopeButtonTitles] objectAtIndex:searchOption]];
// Return YES to cause the search result table view to be reloaded.
return YES;
}
祝你好运,
达明