Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

searchBarCancelButtonClicked delegate method is not called. Is there any way to call?

Tags:

UIViewController to implement a view to placing an UITableView UISearchBar and being implemented. But you can not call searchBarCancelButtonClicked. Do not know what the reason.

like image 633
Szakma Avatar asked Dec 06 '10 16:12

Szakma


2 Answers

The reason why searchBarCancelButtonClicked does not fire may be because your UISearchBar does not show the Cancel button. You can display the Cancel button like this:

searchBar.showsCancelButton = true 

I had the same problem and making the Cancel button show made searchBarCancelButtonClicked fire as expected.

like image 155
Chris Balavessov Avatar answered Sep 19 '22 13:09

Chris Balavessov


Ensure that your UIViewController is set as the delegate of your UISearchBar, and that it adopts the UISearchBarDelegate protocol.

like image 22
GendoIkari Avatar answered Sep 20 '22 13:09

GendoIkari