gpt4 book ai didi

objective-c - 为什么 UISearchBar 在向后导航时出现奇怪的闪烁?

转载 作者:太空狗 更新时间:2023-10-30 03:29:10 25 4
gpt4 key购买 nike

我的 UINavigationItem 的 titleView 中有一个 UISearchBar 与 UISearchController 关联。当我向后导航时,它似乎在闪烁。有人以前见过这个吗?

vid of flash

@interface HNTileSearchViewController () <HNTileSearchResultsProtocol, SWRevealViewControllerDelegate, UISearchBarDelegate, HNSetSearchFiltersProtocol, HNKeywordResultsProtocol>
...
@property (nonatomic, strong) UISearchController *searchController;
@property (nonatomic, strong) UISearchBar * searchBarTop;
...
@end


@implementation HNTileSearchViewController
...
- (void) customPreSetup {
HNKeywordResultsTableViewController * searchResultsController = [self.storyboard instantiateViewControllerWithIdentifier:HNKeywordResultsTableViewControllerStoryboardIdentifier];
searchResultsController.delegate = self;
_searchController = [[UISearchController alloc] initWithSearchResultsController:searchResultsController];
_searchController.searchResultsUpdater = searchResultsController;
_searchController.hidesNavigationBarDuringPresentation = NO;
_searchController.dimsBackgroundDuringPresentation = NO;
_searchBarTop = _searchController.searchBar;
_searchBarTop.delegate = self;
_searchBarTop.placeholder = NSLocalizedString(@"Search heynay", nil);
_searchBarTop.showsCancelButton = NO;
_searchBarTop.showsScopeBar = NO;
self.navigationItem.titleView = _searchBarTop;
self.definesPresentationContext = YES;
}

- (void) viewDidLoad {
[super viewDidLoad];
[self customPreSetup];
...
}
....
@end

最佳答案

我遇到了同样的问题,我用两种方法解决了:

首先,您可以将 searchStyle 设置为 Prominent:

searchController.searchBar.searchBarStyle = .Prominent

顺便说一句,我是用 Swift 写的,这个解决方案的问题是搜索图标和文本以及占位符的颜色较深,如果背景颜色较深,则看起来很糟糕。

我找到的第二个解决方案是:

 navigationController!.navigationBar.translucent=false
navigationController!.navigationBar.barTintColor=UIColor.redColor()

searchController.searchBar.barTintColor=UIColor.redColor()
searchController.searchBar.searchBarStyle = .Prominent
searchController.searchBar.translucent=false

关键是导航栏和搜索栏都不是半透明的,并且都具有相同的颜色。

希望对你有帮助

关于objective-c - 为什么 UISearchBar 在向后导航时出现奇怪的闪烁?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31346715/

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