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

时间:2014-12-05 06:21:21

标签: ios objective-c uisearchdisplaycontroller

UISearchDisplayController 已弃用 IOS8.0 ,建议改为使用 UISearchController 。< / p>

然后如何使用新的** API**来实现流动:

(来自 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;

您知道, UISearchController 中的 API 是不同的,那该怎么办?

2 个答案:

答案 0 :(得分:2)

来自APPLE DOCUMENTATION

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

答案 1 :(得分:0)

这是一个示例项目,它根据youtube上的Vea Software教程视频替换UISearchDisplayController和UISearchController。

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

注意:上面的项目使用swift