ios - 在 UISearchDisplayController 中添加 UISegmentedControl

标签 ios uitableview uisearchbar uisegmentedcontrol uisearchdisplaycontroller

我想添加 UISegmentedControl低于searchBar及以上UISearchDisplayController的TableView .目前UISearchDisplayController仅显示其tableView根据其SearchBar .

但我想添加一个 UISegmentedControl低于SearchBar所以我有SearchBar在顶部,在 SearchBar 之后我有一个 UISegmentedControl及以下 UISegmentedControl我有 UITableView .使用 UISearchDisplayController 有什么方法吗?或者我必须自己制作SearchDisplayController有自己的SearchBar , UISegmentedControlTableView ?

有什么建议吗?谢谢

最佳答案

启用 ShowScopeBar并通过添加范围标题添加尽可能多的段并通过以下方法处理它们

按代码

UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
    [searchBar setShowsScopeBar:YES];
    [searchBar setScopeButtonTitles:@[@"button1",@"button2"]];
    [[self view] addSubview:searchBar];

作者:XIB

enter image description here

处理范围按钮操作的委托(delegate)方法
- (void)searchBar:(UISearchBar *)searchBar selectedScopeButtonIndexDidChange:(NSInteger)selectedScope{


}

关于ios - 在 UISearchDisplayController 中添加 UISegmentedControl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30994608/

相关文章:

ios - 如何在 Swift 中实例化 NSViewController?

ios - 从 viewForHeaderInSection 中的 UIButton 获取数据发送到 add Target 中的方法

ios - 重新加载数据后,我可以在 tableView 中保持相同的位置吗?

ios - Objective C - cellForRowAtIndexPath 单元格永远不会为零?

ios 如何添加一个 inputAccessoryView?

ios - 带拖动的 UITableView

ios - uiviewcontroller 没有从 ios 中的父类导入

ios - iOS 7.1 中 UISearchBar 的 UITextField

ios - 为什么在 UISearchBar 上打字时 UISearchController 消失了?

iphone - 将 UISearchBar 中的 BookmarkButton 替换为 Activityindicator