I have added a search bar above a collection view controller. On activating the search controller the UISearchcontroller.isActive is returning "true" but while editing it's returning "false". But in tableview controller the same implementation working fine. Can anyone explain please what is the reason and how to solve it?
var resultSearchController = UISearchController()
func viewdidLoad() {
self.resultSearchController = UISearchController(searchResultsController: nil)
self.resultSearchController.searchResultsUpdater = self
self.resultSearchController.searchBar.delegate = self
self.definesPresentationContext = true
self.resultSearchController.dimsBackgroundDuringPresentation = false
self.resultSearchController.searchBar.placeholder = "Search for Stores"
self.resultSearchController.searchBar.searchBarStyle = UISearchBarStyle.prominent
self.resultSearchController.searchBar.sizeToFit()
collectionView?.delegate = self
collectionView?.dataSource = self
}
func updateSearchResults(for searchController: UISearchController) {
print(self.resultSearchController.isActive)
}