Reputation: 151
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
}
Upvotes: 3
Views: 693
Reputation: 1333
You need add in viewDidLoad() :
searchController.hidesNavigationBarDuringPresentation = false
Upvotes: 0
Reputation: 4659
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
Upvotes: 7