简体   繁体   中英

UISearchDisplayController - Method for when cancel button is clicked

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?

You can use the following searchbar delegate method,

- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
{
     // DO ur operations
}

For UISearchDisplayController, the following 2 methods can be considered.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM