Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UISearchBar and resignFirstResponder

I have a very basic UITableView with an attached UISearchBar, and here's the flow of what happens

UITableView is empty, user taps UISearchBar, and brings up keyboard. Once the user taps the Search button

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar { 
    [searchBar resignFirstResponder]; //move the keyboard out of the way
    //Code....  
}

Works just fine, and moves the keyboard out of the way, and populates the UITableView. The problem is any subsequent search attempts.

The same steps as before occur, however the keyboard is never dismissed. I have a feeling something else is becoming the responder, I just need a little clarity to understand what is actually occurring.

like image 424
Bryan Clark Avatar asked Aug 06 '10 13:08

Bryan Clark


1 Answers

Without seeing your code it is difficult to guess. However, if you include:

[self.view endEditing:YES];

all views will resign first responder.

like image 152
RunLoop Avatar answered Oct 19 '22 22:10

RunLoop