gpt4 book ai didi

ios - UISearchBar 的范围栏在 iOS 7 中没有显示?

转载 作者:可可西里 更新时间:2023-11-01 03:58:13 25 4
gpt4 key购买 nike

我正在创建一个 UISearchViewController,我希望将 UISearchBar 放在导航 Controller 的导航项中。这是我没有结果的方法:

self.searchBar = [UISearchBar new];
self.searchBar.showsScopeBar = YES;
self.searchBar.scopeButtonTitles = @[@"Users", @"Hashtags"];
self.searchBar.delegate = self;

self.searchController = [[UISearchDisplayController alloc] initWithSearchBar:self.searchBar contentsController:self];
self.searchController.delegate = self;
self.searchController.searchResultsDataSource = self;
self.searchController.searchResultsDelegate = self;
self.searchController.displaysSearchBarInNavigationBar = YES;

我也试过:

self.searchDisplayController.searchBar.searchBarStyle = UISearchBarStyleMinimal;
self.searchDisplayController.searchBar.scopeButtonTitles = @[@"Users", @"Hashtags"];
self.searchDisplayController.searchBar.showsScopeBar = YES;

我是不是遗漏了什么或做错了什么?

编辑:Thisthis这正是我的目标。

最佳答案

试试下面的代码

UISearchBar* searchBar = [[UISearchBar alloc] initWithFrame:CGRectZero];
searchBar.barStyle = UIBarStyleBlack;
searchBar.scopeButtonTitles = [NSArray arrayWithObjects:@"Users", @"Hashtags", nil];
searchBar.showsScopeBar = YES;
self.searchBar.delegate = self;

关于ios - UISearchBar 的范围栏在 iOS 7 中没有显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22033306/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com