searchDisplayController'已被弃用:首先在iOS 8.0中不推荐使用

在这里我的代码:需要删除我的警告。 我在iOS 9下

- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText{ if (searchText.length>0) { self.searchBarActive = YES; [self filterContentForSearchText:searchText scope:[[self.searchDisplayController.searchBar scopeButtonTitles] objectAtIndex:[self.searchDisplayController.searchBar selectedScopeButtonIndex]]]; [self.collectionView reloadData]; }else{ // if text lenght == 0 // we will consider the searchbar is not active self.searchBarActive = NO; } } 

需要删除我的警告,因为我提到我的问题。它应该与iOS 7上面的工作。我是新来的ios。 但是需要删除我的警告信息。我已经尝试了下面的代码:

 if([UISearchController class]){ //Create an UISearchController and add it to your UITableViewController }else{ //Create an UISearchDisplayController and add it to your UITableViewController } 

但严重的是我不知道该怎么实现。如果任何人帮我用代码解释,将有助于我进一步了解进一步的行动。感谢@@

。H

@property (strong, nonatomic) UISearchController *searchController;

.M

 [self filterContentForSearchText:searchText scope:[[self.searchController.searchBar scopeButtonTitles] objectAtIndex:[self.searchController.searchBar selectedScopeButtonIndex]]]; 

这个编码工作得很好….