searchDisplayController' 已弃用:首先在 iOS 8.0 中弃用
searchDisplayController' is deprecated: first deprecated in 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;
}
}
需要删除我在 question.It 中提到的警告应该适用于上述 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
}
但说真的,我不知道如何实现它。如果有人帮助我解释代码,将有助于我进一步了解 move.Thanks @@
.h
@property (strong, nonatomic) UISearchController *searchController;
.m
[self filterContentForSearchText:searchText scope:[[self.searchController.searchBar scopeButtonTitles] objectAtIndex:[self.searchController.searchBar selectedScopeButtonIndex]]];
此编码运行良好....
这是我的代码:需要删除我的警告。我在 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;
}
}
需要删除我在 question.It 中提到的警告应该适用于上述 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
}
但说真的,我不知道如何实现它。如果有人帮助我解释代码,将有助于我进一步了解 move.Thanks @@
.h
@property (strong, nonatomic) UISearchController *searchController;
.m
[self filterContentForSearchText:searchText scope:[[self.searchController.searchBar scopeButtonTitles] objectAtIndex:[self.searchController.searchBar selectedScopeButtonIndex]]];
此编码运行良好....