2017.3.8
实现search的代理方法
- (void)searchBar:(UISearchBar*)searchBar textDidChange:(NSString*)searchText {
if(searchText !=nil&& searchText.length>0) {
self.showDataList= [NSMutableArrayarray];
for(NSString*strinself.dataList) {
if([strrangeOfString:searchTextoptions:NSCaseInsensitiveSearch].length>0) {
[self.showDataListaddObject:str];
}
}
[self.myChoiceTableViewreloadData];
}else{
self.showDataList= [NSMutableArrayarrayWithArray:self.dataList];
[self.myChoiceTableViewreloadData];
}
SearchViewController*search = [[SearchViewControlleralloc]init];
search.hidesBottomBarWhenPushed=YES;
[self.navigationControllerpushViewController:searchanimated:YES];
}
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
[self.searchBar resignFirstResponder];
}
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
[self.searchBar resignFirstResponder];
}