iOS 11 search bar keeps disappearing when typing i have tried to set the searchController.hidesNavigationBarDuringPresentation = false also the searchController.definesPresentationContext = true here is a video of what is going on
My delegate function
func updateSearchResults(for searchController: UISearchController) {
filarr = arr.filter({ (arr:String) -> Bool in
if arr.contains(searchController.searchBar.text!){
return true
}else{
return false
}
})
resultController.tableView.reloadData()
}
//Assigning the searchbarcontroller
if #available(iOS 11.0, *) {
self.navigationController?.navigationBar.prefersLargeTitles = true
self.navigationItem.searchController = searchController
self.navigationItem.hidesSearchBarWhenScrolling = false
} else {
tableView.tableHeaderView = searchController.searchBar
}
You need to set definesPresentationContext to true on the view controller which presents your searchController.
Your are doing this:
searchController.definesPresentationContext = true
but should do this:
definesPresentationContext = true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With