iOS 有没有办法在 TableviewHeader 中保持 UISearchBar 处于活动状态

iOS Is there a way to keep the UISearchBar in TableviewHeader when active

在我正在创建的当前应用程序中,我想知道是否有一种方法可以防止 UISearchController 搜索栏在 UInavigationbar 处于活动状态时移动到 UInavigationbar 中。我已经将它添加到 tableview tableHeadeView 中,但我想将它保留在那里而不是在活动时成为 UInvagiationbar。基本上我不想在搜索处于活动状态时隐藏 UInavigationController 导航栏。我怎样才能做到这一点?

我已经尝试将这段代码添加到用于更新文本的 searchController 委托方法中,但没有成功:

[self.navigationController setNavigationBarHidden:NO animated:YES];

当前代码:

friendsSearchController = [[UISearchController alloc]initWithSearchResultsController:nil];
friendsSearchController.searchResultsUpdater = self;
friendsSearchController.dimsBackgroundDuringPresentation = NO;
friendsSearchController.searchBar.delegate = self;

friendsSearchController.searchBar.searchBarStyle = UISearchBarStyleMinimal;
friendsSearchController.searchBar.placeholder =  @"Find friends";
[friendsSearchController.searchBar sizeToFit];

self.tableView.tableHeaderView = friendsSearchController.searchBar;

hidesNavigationBarDuringPresentation 属性 of UISearchController 判断搜索时是否隐藏导航栏。将其设置为 NO

friendsSearchController.hidesNavigationBarDuringPresentation = NO;