Normally we use the resignFirstResponder to hide the keyboard in the iphone apps. For example, when we use a UISearchBar, after the user click the search button, we hide the keyboard by implement the searchBarSearchButtonClicked function like this:
-(void)searchBarSearchButtonClicked:(UISearchBar*)searchBar{
NSLog(@"Search Button Click, result should be show here");
[searchBar setShowsCancelButton:NO animated:YES];
[searchBar resignFirstResponder];
self.dictTableView.allowsSelection = YES;
self.dictTableView.scrollEnabled = YES;
}
We set the searchBar as the first responder, then the keyboard will be hidden after the user click the search button.
Why it works like this? We didn't call any function that hide the keyboard, we just set the searchBar as the first responder, why the system just hide the keyboard automatically?
Could anyone explain the mechanism of this process?
Thank you very much!