I was wondering if its possible to activate a UISearchDisplayController from a button in the navigation bar rather than from the standard search bar that you get when you pull out the Search Bar Controller from there object library in Xcode. Like this functionality in the calendar app:
You can get a button to fire an action like so:
[self.searchDisplayController setActive:YES animated:YES];
But you still need the search bar and it animates from where the search bar is. Ideally I'd like it coming in from the top like in the gif.
Any help much appreciated. David.
Old question, but I have an answer so I thought it was worth revisiting...
In the end I used UISearchController rather than UISearchDisplayController.
If you want to activate the search, but don't want a search bar, all you have to do it activate the search using
self.searchController.active = YES;
and then because there is no search bar you have to implement the presentSearchController: methods of UISearchControllerDelegate protocol yourself.
- (void)presentSearchController:(UISearchController *)searchController {
[self.window.rootViewController presentViewController:self.searchController animated:YES completion:nil];
}
It doesn't quite have the same animation, but I'm sure using the usual view controller animation api I can get something similar working.
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