【发布时间】:2015-09-10 05:33:53
【问题描述】:
我有一个与 UISearchController 耦合的 UITableView。
通过将搜索栏作为表格视图标题进行连接,如下所示:
tableView.tableHeaderView = searchController.searchBar
我在侧面的索引栏和部分标题之间进行链接,如下所示:
func tableView(tableView: UITableView, sectionForSectionIndexTitle title: String, atIndex index: Int) -> Int {
if searchPredicate != nil {
for (index, section) in enumerate(filteredSections) {
if section.name == title {
return index
}
}
return 0
} else {
return self.fetchedResultsController.sectionForSectionIndexTitle(title, atIndex: index)
}
}
这很好用。
当搜索栏处于活动状态时,它在滚动时始终保持可见(这是预期的行为)。
我的问题是当我点击侧面索引栏中的一个索引字母时。它滚动到节标题,但由于搜索栏在活动时始终可见,我们看不到节标题标题和节第一行的一部分,我们必须手动滚动。
就像这张快照一样,我点击了索引字母L:
有没有办法修复它(接受任何黑客攻击)?
【问题讨论】:
标签: ios swift uitableview uisearchcontroller