下面是最常用的几个SearchBarDelegate:
- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar{ //已经开始编辑 }// called when text starts editing
- (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar{ NSLog(@"收键盘监听"); }// called when text ends editing
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText{ //searchText是searchBar上的文字 每次输入或删除都都会打印全部 }// called when text changes (including clear)
//点击键盘上搜索时的相应事件 - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{ }// called when keyboard search button pressed