For a UISearchBar with UISearchDisplayController, when the searchfield is clicked, the keyboard appears and an overlay shows over the tableview. When cancel is clicked
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
is called.
I am wondering if there is a method called when the overlay is clicked. It does dismiss the keyboard and go back to the tableview. Basically I want to make clicking this overlay run the same method as when cancel is clicked. Any ideas? I checked the Apple Docs and couldn't find anything other than the cancel button method.
You can subclass UISearchDisplayController and call this cancel method from touchesBegan method:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
You can assign the UITapGestureRecognizer to the overlayView.