I have a search bar and i want to detect when the user click it , and after to disable a button while the user is editing in search bar. How can i do this , because i was trying to do wha you will see above but it's never called.
-(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{
NSLog(@"yes");
}
Other methods like searchDisplayController
are called.I set also
self.searchBar.delegate=self
but no result.
Swift version of the answer:
searchBarShouldEndEditing or searchBarSearchButtonClicked
or
You can directly use the delegate of the UIsearchbar for getting the click event. you can use this delegate for it for checking the click. and for getting end editing this second one.
End Editing
The
searchBarSearchButtonClicked:
method is called when the user taps the "Search" (return) button on the keyboard. From you question, I understand that you want to detect when the user taps the search bar, to enter text for the search. If that's the case, you need to implement thesearchBarShouldBeginEditing:
orsearchBarTextDidBeginEditing:
methods in the UISearchBarDelegate. For example,