Specifically, with iOS 11 (and not previous OS), when you tap a search bar to start typing, it jumps to the top of the screen.
I can fix this when the search bar is already near the top of the screen by using this code:
if #available(iOS 11, *) {
navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = false
} else {
BugsTable.tableHeaderView = searchController.searchBar
}
But, when I have a search bar in the middle of a view (i.e some other element is above it), that code won't work as it is telling the search bar inside the navigation controller. I saw the following questions, but no working answer for Swift:
iOS 11 search bar jumping to top of screen
iOS 11 Searchcontroller jumps top of screen
My ViewDidLoad setup parameters are:
searchController.searchResultsUpdater = self
searchController.hidesNavigationBarDuringPresentation = false
searchController.dimsBackgroundDuringPresentation = false
searchController.searchBar.sizeToFit()
ResultsTable.tableHeaderView = searchController.searchBar
searchController.searchBar.barTintColor = MyGlobalVariable.themeMainColor
What am I missing here?