【发布时间】:2016-07-18 18:41:55
【问题描述】:
所以我有一个连接到视图控制器的导航控制器。这显然提供了默认导航栏。在此之下,我有另一个带有两个按钮的导航栏。在代码中,我手动将 UISearchController 提供的搜索栏添加到该导航栏。在此之下,有另一个过滤视图(自定义),然后是 UITableView。一切似乎都正常,但是当我单击搜索并开始输入时,结果视图覆盖了第二个导航栏和搜索栏,使其有点无用。我试着玩 self.searchController.hidesNavigationBarDuringPresentation = NO;但这只是隐藏了主导航栏。更令人气愤的是结果视图控制器实际上为第二个导航栏留出了空间,但它只是隐藏在这个后面。甚至可以在 debug view heirachy 菜单中看到这一点。这是我用于搜索控制器的代码:
CUSearchResultsTableViewController *results = [self.storyboard instantiateViewControllerWithIdentifier:@"searchResults"];
self.searchController = [[UISearchController alloc] initWithSearchResultsController:results];
self.searchController.searchResultsUpdater = self;
self.searchBarNavItem.titleView = self.searchController.searchBar;
self.searchController.hidesNavigationBarDuringPresentation = NO;
self.searchController.obscuresBackgroundDuringPresentation = NO;
self.searchController.dimsBackgroundDuringPresentation = NO;
self.definesPresentationContext = YES;
self.searchController.delegate = self;
self.searchController.searchBar.delegate = self;
【问题讨论】:
-
您找到解决此问题的方法了吗?
标签: ios objective-c uinavigationcontroller uinavigationbar uisearchcontroller