UISearchDisplayController在IOS8.0中被弃用,那么如何初始化呢?

UISearchDisplayControllerIOS8.0已被弃用,build议使用UISearchController代替。

那么如何使用新的** API**来实现stream动:

(从Beginning IOS7 Development Exploring the IOS SDK

 UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)]; tableView.tableHeaderView = searchBar; searchContoller = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self]; searchController.delegate = self; searchController.searchResultsDataSource = self; 

你知道, UISearchControllerAPI是不同的,那该怎么办?

从苹果文档 :

 searchController = [[UISearchController alloc] initWithSearchResultsController:nil]; searchController.searchResultsUpdater = self; searchController.dimsBackgroundDuringPresentation = NO; searchController.hidesNavigationBarDuringPresentation = NO; searchController.searchBar.frame = CGRectMake(self.searchController.searchBar.frame.origin.x, self.searchController.searchBar.frame.origin.y, self.searchController.searchBar.frame.size.width, 44.0); self.tableView.tableHeaderView = self.searchController.searchBar; 

在UISearchController上检查这个SAMPLE PROJECT 。

以下是一个示例项目,它基于YouTube上的Vea Software教程video,用UISearchControllerreplaceUISearchDisplayController。

https://github.com/2015HuntMJ/UISearchController

注意:上面的项目使用swift