I set up a UISearchController
like this:
searchResultsController = SearchResultsController()
searchController = UISearchController(searchResultsController: searchResultsController)
searchController.searchResultsUpdater = self
searchController.hidesNavigationBarDuringPresentation = false
searchController.dimsBackgroundDuringPresentation = true
searchController.searchBar.searchBarStyle = .minimal
searchController.delegate = self
definesPresentationContext = true
navigationItem.titleView = searchController.searchBar
SearchResultsController
is just a view controller with UITableView
to show search results.
When the device is in portrait, start searching in portrait mode, there is an extra space on top of the table view (the RESULT header is the start of table view)
Then if I rotate to landscape mode, the space disappeared:
When device is in landscape mode and I start search, then the table view is cut off:
Then if I rotate to portrait, the table view fits perfectly:
The extra space height is exactly same as status bar height. So I wonder there is something related to the status bar here.
This didn't happen if I assign the searchbar as table view's tableHeaderView
. It only happens when searchbar is in navigation title. Anyone know why?