Reputation: 115
Hi I am new to xcode development I am creating a simple application. In that I have table view Controller with on Search bar control. onClick
of Search bar Key board comes up I am not able to hide the key board. I tried to Hide it by
(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
[self resignFirstResponder];
[self.searchbar setShowsCancelButton: NO animated: YES];
}
but It is not working.
Upvotes: 0
Views: 773
Reputation: 92
I hope this will help you
if([text length] == 0) {
[searchBar performSelector: @selector(resignFirstResponder)
withObject: nil
afterDelay: 0.1];
}
where text is searchbar text
Best of luck
Upvotes: 0
Reputation: 3286
To hide keyboard, you should lose focus on the text input, not the class instance itself (self)
In your case, you should do
[searchBar resignFirstResponder]
Upvotes: 1