UISearchBar 点击X 按钮收键盘
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText;{ NSLog(@"textDidChange---%@",searchBar.text); if (searchBar.text.length == 0) { [self performSelector:@selector(hideKeyboardWithSearchBar:) withObject:searchBar afterDelay:0]; } } - (void)hideKeyboardWithSearchBar:(UISearchBar *)searchBar { [searchBar resignFirstResponder]; }