Ios 将搜索栏添加到现有标题Swift 3

Ios 将搜索栏添加到现有标题Swift 3,ios,swift3,uisearchcontroller,Ios,Swift3,Uisearchcontroller,我一直在基于Ray Wenderlich教程()的Swift 3项目中添加搜索框和搜索选项卡栏 这对大多数表都很有效。但是,我的一个表的标题已在情节提要中定义。如果我使用如下所示的代码,它将替换故事板中定义的标题,并且还有一些其他副作用 因此,我想知道如何执行以下操作之一: a) 使用代码将搜索栏附加到现有标题 b) 在故事板中添加一个搜索栏对象,然后正确设置插座,以便我的其他搜索代码引用它 我有以下代码 毫无疑问 searchController.searchResultsUpdater =

我一直在基于Ray Wenderlich教程()的Swift 3项目中添加搜索框和搜索选项卡栏

这对大多数表都很有效。但是,我的一个表的标题已在情节提要中定义。如果我使用如下所示的代码,它将替换故事板中定义的标题,并且还有一些其他副作用

因此,我想知道如何执行以下操作之一:

a) 使用代码将搜索栏附加到现有标题 b) 在故事板中添加一个搜索栏对象,然后正确设置插座,以便我的其他搜索代码引用它

我有以下代码

毫无疑问

searchController.searchResultsUpdater = self
searchController.dimsBackgroundDuringPresentation = false
definesPresentationContext = true
searchController.searchBar.scopeButtonTitles = ["All", "Active", "Not Active"]
searchController.searchBar.delegate = self
tableView.tableHeaderView = searchController.searchBar
主类之上的扩展

extension ItemsViewController: UISearchResultsUpdating{
    func updateSearchResults(for: UISearchController) {
        filterContentForSearchText(searchText: searchController.searchBar.text!)
    }
}

extension ItemsViewController: UISearchBarDelegate {
    func searchBar(_ searchBar: UISearchBar, selectedScopeButtonIndexDidChange selectedScope: Int) {
        //filterContentForSearchText(searchText: searchController.searchBar.text!)
        filterContentForSearchText(searchText: searchBar.text!, scope: searchBar.scopeButtonTitles![selectedScope])
    }
}
过滤代码

    func filterContentForSearchText(searchText: String, scope: String = 
... filter logic ..     
tableView.reloadData()
    }
任何想法都将不胜感激