gpt4 book ai didi

ios - UISearchBar 后面可见的范围栏

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

我在 iOS9 中遇到了这种奇怪的行为,当 ViewController 第一次出现时,范围栏就在 UISearchBar 后面可见:

Bug

按下“搜索”后,UISearchBar 的行为符合预期(UISearchBar 移至顶部,范围栏位于下方)。完成搜索或点击取消后,它会返回到我希望从头开始的状态:

Subsequent correct look

在 viewDidLoad 方法中,我按如下方式初始化 UISearchController:

    self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
self.searchController.searchResultsUpdater = self;
self.searchController.dimsBackgroundDuringPresentation = NO;
self.searchController.searchBar.autocorrectionType = UITextAutocorrectionTypeNo;
self.searchController.searchBar.autocapitalizationType = UITextAutocapitalizationTypeNone;
[self.searchController.searchBar sizeToFit];

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

self.searchController.searchBar.delegate = self;
self.searchController.searchBar.scopeButtonTitles = @[[self titleForScopeButton:ScopeButtonIdNameDesc],
[self titleForScopeButton:ScopeButtonIP]];

有什么想法吗?

最佳答案

我没有在那个应用程序上工作过一点,忘记了我在 appDelegate 的 didFinishLaunchingWithOptions 中设置了 UISearchBar 的整体外观。

[[UISearchBar appearance] setSearchBarStyle:UISearchBarStyleMinimal];
[[UISearchBar appearance] setBackgroundColor:[PCConstantsGUI tintColor]];
[[UISearchBar appearance] setTintColor:[PCConstantsGUI tintColor]];

导致渲染问题的罪魁祸首是“UISearchBarStyleMinimal”,在我不得不用 UISearchController 替换已弃用的 UISearchDisplayController 之前它看起来很漂亮。

关于ios - UISearchBar 后面可见的范围栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34499913/

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