1
votes

Custom UITableViewController for UISearchController overlays the search bar in iOS 11 when you set the search controller to the navigationItem.searchController. The table view controller covers the whole screen so you cannot see the search bar while typing. This is not an issue when you send nil to UISearchController. Basically, I have a search bar for this map app, so I am setting a UITableViewController to the UISearchController to handle the display of the search result when searching for location. Previously, the table view shows up at the bottom of the search bar, now it covers the whole screen.

Here's a code snippet:

    searchController = UISearchController(searchResultsController: searchResultsController)
    searchController.searchBar.sizeToFit()
    searchController.hidesNavigationBarDuringPresentation = true
    searchController.dimsBackgroundDuringPresentation = true
    searchController.definesPresentationContext = false
    searchController.searchResultsUpdater = self
    searchController.delegate = self

    if #available(iOS 11.0, *){
        self.navigationItem.searchController = searchController
    }
1

1 Answers

0
votes

Found the issue. Need to set the right origin value in willPresentSearchController