gpt4 book ai didi

ios - scopeBar 第一次激活时不显示在 UISearchBar 下

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:37:52 24 4
gpt4 key购买 nike

我以编程方式创建了一个 UISearchController,并在 viewDidLoad 中设置范围按钮标题

UITableViewController *searchResultsController = [[UITableViewController alloc] initWithStyle:UITableViewStylePlain];
searchResultsController.tableView.dataSource = self;
searchResultsController.tableView.delegate = self;
[searchResultsController.tableView registerNib:musicNib forCellReuseIdentifier:@"MusicCell"];

self.searchController = [[UISearchController alloc] initWithSearchResultsController:searchResultsController];
self.searchController.searchResultsUpdater = self;
UISearchBar *searchBar = self.searchController.searchBar;
searchBar.scopeButtonTitles = @[@"Album", @"Artist", @"Song"];
searchBar.showsScopeBar = YES;
searchBar.selectedScopeButtonIndex = 0;
searchBar.delegate = self;

self.tableView.tableHeaderView = self.searchController.searchBar;

但是当我在 View 加载时在搜索栏中搜索时。范围栏不显示。第二个我在搜索栏中搜索,范围栏显示。怎么回事?

first time search, scope bar don't show second time search, scope bar shows

最佳答案

试试这个:

searchBarDisplayController.searchBar.showsScopeBar = NO;
searchBarDisplayController.searchBar.scopeButtonTitles = nil;

根据您的评论,将上述代码放在 searchDisplayControllerWillBeginSearch: 委托(delegate)方法中。这应该有效。

关于ios - scopeBar 第一次激活时不显示在 UISearchBar 下,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26416972/

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