我有一个导航栏,当屏幕第一次显示时,其上没有搜索栏显示。我在导航栏中触发并显示搜索栏,但我想知道如何隐藏搜索栏并再次显示导航栏标题。如何隐藏UINavigationBar中的UISearchController
我创建的搜索栏如下:
_searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
self.searchController.searchResultsUpdater = self;
self.searchController.searchBar.placeholder = nil;
[self.searchController.searchBar sizeToFit];
//self.tableView.tableHeaderView = self.searchController.searchBar;
self.sharedNavigationItem.titleView = _searchController.searchBar;
self.searchController.delegate = self;
self.searchController.dimsBackgroundDuringPresentation = NO; // default is YES
self.searchController.searchBar.delegate = self; // so we can monitor text changes + others
self.definesPresentationContext = YES;
_searchController.hidesNavigationBarDuringPresentation = NO;
我只想在这里隐藏搜索栏和带有标题显示正常导航栏:
您是否尝试更改self.sharedNavigationItem.titleView? –