我有一個導航欄,當屏幕第一次顯示時,其上沒有搜索欄顯示。我在導航欄中觸發並顯示搜索欄,但我想知道如何隱藏搜索欄並再次顯示導航欄標題。如何隱藏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? –