UISearchController 重叠 TableView 的滚动视图。解决这个问题的最佳方法?

UISearchController Overlapping TableView's scrollview. Best Way to Get Around This?

刚刚完成 Ray Wenderlich 的 "UI Search Controller" 教程,在该教程中我创建了一个带有范围按钮项的搜索栏:

https://www.raywenderlich.com/113772/uisearchcontroller-tutorial

我让它工作没问题,除了范围按钮与我的 tableview scrollview 的第一个结果重叠的小例外:Picture Here

在我的应用程序中,我使用了一个嵌入在 UIViewController 中的 tableView,我猜这可能是问题所在。我已经 "Adjusts Scroll View Insets" 检查了我的 UIViewController,但没有解决问题。甚至尝试取消选中它可能是问题所在的奇怪机会,但仍然无法正常工作。

我认为问题与教程中将 searchBar 作为 tableView 的 headerView 添加有关:

 tableView.tableHeaderView = searchController.searchBar

但是,我不知道为什么它不会对看起来像 UINavigationController 的东西造成任何问题,但是对于将它嵌入 UITableViewController 内的 tableView 的人来说却会造成问题。

非常感谢任何help/workaround建议!非常感谢您。

编辑:代码实例化搜索控制器,遵循 Wenderlich 教程:

        searchController.searchBar.scopeButtonTitles = ["All","party", "hangout", "recreation", "event", "other"]
        searchController.searchBar.tintColor = UIColor().crimson()

        searchController.searchBar.delegate = self

        //MARK: Search controller initialization
        searchController.searchResultsUpdater = self
        searchController.dimsBackgroundDuringPresentation = false

答案发现:实现tableView中的heightForHeaderInSection方法,return高度。可以在这里找到答案: