Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone SDK: UISearchBar: searchBarTextDidEndEditing not firing

I'm implementing a search bar on my table, which should be pretty straight forward. I've got these:

- (void)searchBarTextDidBeginEditing:(UISearchBar *)theSearchBar { 
 NSLog(@"searchBarTextDidBeginEditing");
}

- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {    
    NSLog(@"The search text is: %@", searchText);
}

- (void)searchBarTextDidEndEditing:(UISearchBar *)theSearchBar {
    NSLog(@"searchBarTextDidEndEditing");
    [theSearchBar resignFirstResponder];
}

And searchBarTextDidBeginEditing fires, and I get that message in my log, but when I tap outside the search bar, above the keyboard, I don't get the searchBarTextDidEndEditing event so I can't make the keyboard disappear – the message doesn't even appear in the log.

The textDidChange is working, so it's just searchBarTextDidBeginEditing that isn't.

Any ideas? Thanks!!

like image 973
Nick Avatar asked Dec 16 '22 22:12

Nick


2 Answers

Even i faced the same problem.

Please find with the solution below

Implement Below methods

1.searchBarTextDidEndEditing
2.searchBarSearchButtonClicked

and make sure you [UISearchchbar resignfirstresponder] in the second method mentioned above

like image 167
Namburi.Rajesh Avatar answered Jan 19 '23 01:01

Namburi.Rajesh


Once I implemented searchBarSearchButtonClicked that solved it for me.

like image 37
Pickles Avatar answered Jan 19 '23 00:01

Pickles