Reputation: 137
I have this UISearchDisplayController
and so far it can only be activated (ready to type with a drop down searchresulttableview
) when someone clicks the UISearchBar
. Is there a way to make a button do this task? I will appreciate any answer I receive.
Upvotes: 2
Views: 707
Reputation: 6394
Since UISearchBar
extends UIResponder
just like a UITextField
, you can simply call becomeFirstResponder
on the search bar to give it focus.
[button addTarget:self action:@selector(clickedSearchBar) forControlEvents:UIControlEventTouchUpInside];
- (void)clickedSearchBar {
[searchDisplayController.searchbar becomeFirstResponder];
}
Upvotes: 1
Reputation: 318824
Look at the docs for UISearchDisplayController
. There is an active
property and a setActive:animated:
method.
Have your button action call this:
[theSearchController setActive:YES animated:YES];
Upvotes: 2
Reputation: 736
Have you tried [searchDisplayController.searchbar becomeFirstResponder]
inside your button selector?
Upvotes: 3