How to allow the user to close a searchDisplayController?
Here is what I'm talking about:
As you can see, by default there开发者_如何学JAVA is no way to get out of this view unless the user taps a row in the TableView, in which case you can dismiss the view. If only there was some way I could intercept the cancel button press that would be a way, but I'm not sure it's possible.
So, my question is, how can I allow the user to cancel out of this modal view?
Delegate methods to the rescue: why don't you set up a delegate for the search display controller's searchBar
, and implement searchBarCancelButtonClicked:
? You'll have to give the delegate a reference back to the display controller; or, better, the display controller could itself be the delegate.
Or am I missing something about your question?
You could either wrap your modal tableview controller in a navigation controller and add a done button to your table view controller's navigation item or implement the UISearchDisplayControllerDelegate method:
- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller
精彩评论