SearchBar方法已弃用问题

时间:2017-05-05 10:31:00

标签: ios objective-c ios7 io ios5

我使用过这种方法,但是它说它已被弃用了。我应该使用哪种方法代替这种方法?

 -(BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
    {
        [self filterContentForSearchText:searchString scope:[[self.searchDisplayController.searchBar scopeButtonTitles] objectAtIndex:[self.searchDisplayController.searchBar selectedScopeButtonIndex]]];

        return YES;
    }

2 个答案:

答案 0 :(得分:0)

UISearchDisplayController类替换UISearchController类

 - (void)updateSearchResultsForSearchController:(UISearchController *)searchController
 {
    // Your logic here
 }

 - (void)searchBar:(UISearchBar *)searchBar selectedScopeButtonIndexDidChange:(NSInteger)selectedScope
 {
  //[self updateSearchResultsForSearchController:searchController];
 }

答案 1 :(得分:0)

Apple Document Says

  

UISearchDisplayController在iOS 8中已弃用。(请注意   UISearchDisplayDelegate也已弃用。)管理   在iOS 8和iOS中显示搜索栏并显示搜索结果   之后,改为使用 UISearchController