I'm building in search functionality into my app, which consists primarily of UITableViews. I have successfully added a search bar, and can search for items properly, but when I set controller.dimsBackgroundDuringPresentation = false things get all weird. The issue is, I do want this boolean to be false, since users should be able to scroll through the results and select a result to see more details.
The behavior that I'm seeing is the following: the search bar never dismisses itself, unless you press the Cancel button, meaning that when I select a cell in my table view to show the details of that cell, the search bar carries over into that view, as such:

I initialize my search controller as follows:
 self.searchController = ({
        let controller = UISearchController(searchResultsController: nil)
        controller.searchResultsUpdater = self
        controller.dimsBackgroundDuringPresentation = false
        controller.searchBar.sizeToFit()
        controller.hidesNavigationBarDuringPresentation = false
        controller.searchBar.searchBarStyle = .Minimal
        controller.delegate = self
        
        self.tableView?.tableHeaderView = controller.searchBar
        return controller;
    })()
and while the searching itself works (updateSearchResultsForSearchController gets called, I apply my search and return an array, etc), I can't seem to use the search in any way, since if I select a cell while searching, the above picture happens, but if I press cancel, then my search is cleared. Any help would be appreciated.
 
     
    