17

I have a UISearchDisplayController that shows the cancel button. I would like to call a method when a user clicks the cancel button. Is there a way to do this?

Nic Hubbard
  • 41,587
  • 63
  • 251
  • 412

2 Answers2

28

You can use the following searchbar delegate method,

- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
{
     // DO ur operations
}
EXC_BAD_ACCESS
  • 2,699
  • 2
  • 21
  • 25
1

For UISearchDisplayController, the following 2 methods can be considered.

- (void)searchDisplayControllerWillEndSearch:(UISearchDisplayController *)controller
{
    NSLog(@"WillEndSearch");
}

- (void)searchDisplayControllerDidEndSearch:(UISearchDisplayController *)controller
{
    NSLog(@"DidEndSearch");
}
Sanlusfa
  • 49
  • 3