我想添加 UISegmentedControl
低于searchBar
及以上UISearchDisplayController
的TableView .目前UISearchDisplayController
仅显示其tableView
根据其SearchBar
.
但我想添加一个 UISegmentedControl
低于SearchBar
所以我有SearchBar
在顶部,在 SearchBar
之后我有一个 UISegmentedControl
及以下 UISegmentedControl
我有 UITableView
.使用 UISearchDisplayController
有什么方法吗?或者我必须自己制作SearchDisplayController
有自己的SearchBar
, UISegmentedControl
和 TableView
?
有什么建议吗?谢谢
最佳答案
启用 ShowScopeBar
并通过添加范围标题添加尽可能多的段并通过以下方法处理它们
按代码
UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
[searchBar setShowsScopeBar:YES];
[searchBar setScopeButtonTitles:@[@"button1",@"button2"]];
[[self view] addSubview:searchBar];
作者:XIB
处理范围按钮操作的委托(delegate)方法
- (void)searchBar:(UISearchBar *)searchBar selectedScopeButtonIndexDidChange:(NSInteger)selectedScope{
}
关于ios - 在 UISearchDisplayController 中添加 UISegmentedControl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30994608/