searchDisplayController在iOS 8中已弃用 [英] searchDisplayController deprecated in iOS 8
问题描述
如何更正以下内容,以免出现警告?
我缺少什么?
How do you correct the following so no warnings appear? What am I missing?
将 searchResultsController
更正为 searchController
它给我一个错误找不到对象
When correcting the searchResultsController
to searchController
it gives me an error "object not found"
if (tableView == self.searchDisplayController.searchResultsTableView) {
cell.textLabel.text = [searchResults objectAtIndex:indexPath.row];
} else {
cell.textLabel.text = [_content objectAtIndex:indexPath.row];
}
return cell;
}
-(BOOL)searchDisplayController:(UISearchDisplayController *)controller
shouldReloadTableForSearchString:(NSString *)searchString
{
[self filterContentForSearchText:searchString
scope:[[self.searchDisplayController.searchBar scopeButtonTitles]
objectAtIndex:[self.searchDisplayController.searchBar selectedScopeButtonIndex]]];
return YES;
}
推荐答案
UISearchController
类替换了UISearchDisplayController
类,用于管理与搜索相关的接口的显示。
The
UISearchController
class replaces theUISearchDisplayController
class for managing the display of search-related interfaces.
来源: https://developer.apple.com/library/ios/releasenotes/General/WhatsNewIniOS/Articles/iOS8.html
所以,正如rmaddy所说,如果你想摆脱已弃用的警告,请停止使用已弃用的类。改为使用 UISearchController
:
So, as rmaddy said, if you want to get rid of the deprecated warnings, stop using the deprecated classes. Use UISearchController
instead:
这篇关于searchDisplayController在iOS 8中已弃用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!