Pressing the search button on the keyboard and then pressing the cancel button doesn’t always dismiss the cancel button even when showCancelButton is equal to false or when tagging IOS 13 for automatic cancel button dismissal. This works in simulator but only 50% of the time on my device. Anyone know of any possible solutions?
func setupSearchController() {
if #available(iOS 13.0, *) {
searchController.automaticallyShowsCancelButton = true
} else {
searchController.searchBar.showCancelButton = false
}
}
func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {
if #available(iOS 13.0, *) {
searchController.automaticallyShowsCancelButton = true
} else {
searchController.searchBar.showCancelButton = false
}
}
func updateSearchResults(for searchController: UISearchController) {
if #available(iOS 13.0, *) {
searchController.automaticallyShowsCancelButton = true
} else {
searchBar.showsCancelButton = true
}
}