searchDisplayController' is deprecated: first deprecated in iOS 8.0

随声附和 提交于 2019-12-08 09:19:25

问题


Here my code: Need to remove my warning . i am under 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;
    }



}

Need to remove my warning as i mention in my question.It should work with above iOS 7. I am new to ios. But need to remove my warning message .I have tried below code:

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

But seriously i don't know how to implement that .If any one help me with code explanation will be helpful me to know for further move.Thanks @@


回答1:


.h

@property (strong, nonatomic) UISearchController *searchController;

.m

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

this coding working well....



来源:https://stackoverflow.com/questions/33527619/searchdisplaycontroller-is-deprecated-first-deprecated-in-ios-8-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!