本文介绍了在 UISearchDisplayController 中添加 UISegmentedControl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 searchBar 下方和 UISearchDisplayController 的 TableView 上方添加 UISegmentedControl.目前 UISearchDisplayController 只在它的 SearchBar 下显示它的 tableView.

I want to add the UISegmentedControl below the searchBar and above the TableView of UISearchDisplayController. Currently UISearchDisplayController only shows its tableView under its SearchBar.

但我想在 SearchBar 下方添加一个 UISegmentedControl,以便在 SearchBar 之后在顶部有 SearchBar代码> 我有一个 UISegmentedControl,在 UISegmentedControl 下面我有 UITableView.有没有办法使用 UISearchDisplayController 做到这一点,或者我必须制作自己的 SearchDisplayController ,它有自己的 SearchBar , UISegmentedControlTableView?

But i want to add a UISegmentedControl below the SearchBar so that I have SearchBar on the top, after SearchBar I have a UISegmentedControl and below that UISegmentedControl I have UITableView. Is that any way to do this using UISearchDisplayController or i have to make my own SearchDisplayController that have its own SearchBar , UISegmentedControl and TableView?

有什么建议吗?谢谢

推荐答案

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

Enable ShowScopeBar and add as many as segments by adding scop titles and handle them by following method

按代码

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

由 XIB

处理范围按钮动作的委托方法

- (void)searchBar:(UISearchBar *)searchBar selectedScopeButtonIndexDidChange:(NSInteger)selectedScope{


}

这篇关于在 UISearchDisplayController 中添加 UISegmentedControl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 04:40