#pragma mark ------------ searchBar 代理方法 -------------------------- - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText { /**< 模糊查找*/ NSPredicate *predicateString = [NSPredicate predicateWithFormat:@"%K contains[cd] %@", @"name", searchText]; self.searchResultArray = [NSArray arrayWithArray:[_allCityArray filteredArrayUsingPredicate:predicateString]]; /**< 精确查找*/ // NSPredicate *predicateString = [NSPredicate predicateWithFormat:@"%K == %@", @"name", searchText]; [self.searchDisplayController.searchResultsTableView reloadData]; }
使用的是 self.searchDisplayController.searchResultsTableView显示搜索的数据;