本文介绍了UISearchDisplayController在IOS8.0中被弃用了,那么如何初始化呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UISearchDisplayControllerIOS8.0 中被弃用,推荐使用 UISearchController 代替.

UISearchDisplayController is deprecated in IOS8.0, and recommended to use UISearchController instead.

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

Then How to use the new **API** to implement the flowing :

(来自开始IOS7开发探索IOS SDK)

(from 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是不同的,那怎么办?

You know, the API in UISearchController is different, then how to do ?

推荐答案

来自 苹果文档:

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.

Check this SAMPLE PROJECT on UISearchController.

这篇关于UISearchDisplayController在IOS8.0中被弃用了,那么如何初始化呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 02:33