我正在构建一个使用新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;
解决方法
只需更改sectionIndex的背景颜色:
迅速:
tableView.sectionIndexBackgroundColor = UIColor.clearColor()