I'm using a UISearchViewController in a slightly non-conventional way.
My UISearchBar is initially hidden. When the user taps a button I unhide the UISearchBar and activate the UISearchViewController. I also set the text of the searchbar, and tell the searchbar to become first responder.
The problem is that the gray overlay created by the UISearchDisplayController remains visible. It doesn't go away unless the text that I preset is cleared, and the user begins typing anew.
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 it's gray overlay, and how do I clear it?
changing the order of the calls seemed to do the trick. not sure why.
[self.searchDisplayController setActive: YES animated: YES];
self.searchDisplayController.searchBar.hidden = NO;
self.searchDisplayController.searchBar.text = @"term";
[self.searchDisplayController.searchBar becomeFirstResponder];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With