In my project I\'m using a UITableViewController
with an internal UISearchController
to filter the data in my tableView
.
I ha
If you implement UISearchResultsUpdating
protocol, you can know that cancelled is triggered when active
is false
.
func updateSearchResultsForSearchController(searchController: UISearchController) {
if !searchController.isActive {
print("Cancelled")
}
}
You need to set the UISearchController
searchBar's
delegate
. Once you have done this, the addition of the delegate method searchBarCancelButtonClicked:
will properly be called.
self.searchController.searchBar.delegate = self;
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
}
Swift 5
searchBar.delegate = self
.......
extension YourClass: UISearchBarDelegate {
func searchBarCancelButtonClicked(_ searchBar: UISearchBar){}
}