iPhone perform action when UITextField / UISearchBar's clear button is pressed
问题 Is it possible to gain access to a delegate method that will allow additional actions to be performed when the "clear" button is pressed on a UITextField / UISearchBar? Thanks 回答1: See: UITextFieldDelegate Protocol Reference If you set your view controller as the delegate for your text field (can be done in interface builder), you can use: - (void)clearSearchTextField { ... } - (BOOL)textFieldShouldClear:(UITextField *)textField { if (textField == self.searchTextField) [self