我正在构建一个使用新 UISearchController 的 iOS 8 应用程序。在与搜索控制器相关的表格视图中,我使用了一个部分索引来让用户从表格的一个部分快速跳转到下一个部分。它工作得很好,但是部分索引与表/搜索控制器上的搜索栏重叠。以前有没有人遇到过这个问题,如果有,你是如何解决的?下面是我如何初始化我的搜索控制器:
self.resultsTableController = [self.storyboard instantiateViewControllerWithIdentifier:[SelectSpecialtySearchResultsTVC storyboardId]];
UINavigationController *searchResultsNavController = [[UINavigationController alloc]initWithRootViewController:self.resultsTableController];
self.searchController = [[UISearchController alloc] initWithSearchResultsController:searchResultsNavController];
self.searchController.searchResultsUpdater = self;
self.searchController.hidesNavigationBarDuringPresentation = NO;
self.searchController.searchBar.barTintColor = [UIColor colorWithHexString:kColorGrayLight];
self.searchController.searchBar.translucent = NO;
self.searchController.searchBar.frame = CGRectMake(self.searchController.searchBar.frame.origin.x, self.searchController.searchBar.frame.origin.y, [self.view bounds].size.width, 44.0);
self.searchController.searchBar.delegate = self;
self.tableView.tableHeaderView = self.searchController.searchBar;
//present the search display controller within the confines of this class's table view
self.definesPresentationContext = YES;
// we want to be the delegate for our filtered table so didSelectRowAtIndexPath is called for both tables
self.resultsTableController.tableView.delegate = self;
self.searchController.delegate = self;