UISearchDisplayController: Cancel as dismiss button
===

I have this problem with `UISearchDisplayController`. I want to use it in a dedicated view for handling searches. For my controller class I used a composition of the searchbar, the searchcontroller and a tableviewcontroller. SearchViewController is linked to a `.xib`. 

    @interface SearchViewController : UIViewController <UISearchBarDelegate, UISearchDisplayDelegate, UITableViewDelegate, UITableViewDataSource> {
      NSSet *words;
      UISearchDisplayController *searchController;
      UISearchBar *searchBar;
      PhraseTableViewController *phraseTableViewController;
    }

As soon as `SearchViewController` appears, the searchbar becomes firstresponder and the search is therefore active. Everything looks and works fine, with **one exception:**
In order to get back to the previous view, I want to use the cancel button of the SearchBar. Now here comes the problem: If the user touches the grey area of the underlying tableview when  no search has been made, the cancel button (and therefore the only way to get back) disappears.

Here's the thing I've tried to solve this: 

 1. `showsCancelButton = YES` on `searchDisplayControllerDidEndSearch`. Works, but the resulting UI is ugly as hell: The cancel button transitions out and then reappears.
 2. Add a `UITapGestureRecognizer` to the searchcontroller's `searchResultTableView` in the hope to catch the tap. Doesn't work, it still goes through.
 3. Subclass `UISearchBar` and override `self.searchController.searchBar setShowsCancelButton:` - Didn't work. 

Ideas how to solve this:

 1. Always hide the cancel button and instead add a custom button. Question: Do you have an idea how to do this such that the UI looks good? What concerns me most is to handle all the cases such that the search-textfield always keeps nicely at the side of the button.
 2. Ditch `UISearchDisplayController` all together for a more flexible solution. Do you know where to look? Pre-iOS 3 this controller didn't exist, right? Aren't there solutions around that still work?

I'm glad for any input of yours. Thanks in advance.

