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?
Asked
Active
Viewed 6,969 times
2 Answers
28
You can use the following searchbar delegate method,
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
{
// DO ur operations
}

EXC_BAD_ACCESS
- 2,699
- 2
- 21
- 25
-
This is valuable, since iOS 7 seems to force the cancel-button for UISearchDisplayControllers. – patric.schenke Dec 13 '13 at 13:44
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