I encountered a lot of issues with iOS 11 and displaying UISearchController
by presenting it over navigation bar (as described here, example from Apple tutorials)
@IBAction func searchAction(sender: UIBarButtonItem) {
// Create the search controller and specify that it should present its results in this same view
searchController = UISearchController(searchResultsController: nil)
// Make this class the delegate and present the search
self.searchController.searchBar.delegate = self
presentViewController(searchController, animated: true, completion: nil)
}
It is hiding app's UINavigationBar
and displaying UISearchController
with search bar.
Issue 1. On iOS 11 it is causing search bar to overlap with status first time it appears (it is not overlaping after trying again).
UISearchController
presented for the first time. No space between status bar and search bar.
UISearchController
presented again, UINavigationBar
is bigger and search bar is way lower status bar.
Issue 2 On iPhone X it is not covering the whole space when presented
I have spend hours trying to figure it out. Is there other, simply way to show search bar on iOS 11 after clicking eg. search icon in navigation bar? Is there a way to fix UISearchController
navigation bar height and space on iPhone X?
UINavigationItem.searchController
is not an alternative since I do not want the search bar to be permanent on the navigation bar. – Uprise