How to activate a UISearchDisplayController with a predefined deadline?

I use the UISearchViewController in a somewhat unconventional way.

My UISearchBar is initially hidden. When the user clicks the button, I show the UISearchBar and activate the UISearchViewController. I also set the text of the search bar and told the search bar to become the first responder.

The problem is that the gray overlay created by the UISearchDisplayController remains visible. This does not disappear if the text that I set is cleared and the user starts to type the text again.

    self.searchDisplayController.searchBar.hidden = NO;
    self.searchDisplayController.searchBar.text = @"term";
    [self.searchDisplayController.searchBar becomeFirstResponder]; // this actually appears to activate everything
    [self.searchDisplayController setActive: YES animated: YES]; // this activates but does not set the searchbar to 1st responder...

Why does the UISearchDisplayController continue to show a gray overlay and how to clear it?

+5
source share
1 answer

, , . .

[self.searchDisplayController setActive: YES animated: YES]; 
 self.searchDisplayController.searchBar.hidden = NO;
self.searchDisplayController.searchBar.text = @"term";
[self.searchDisplayController.searchBar becomeFirstResponder]; 
+12

All Articles