iOS学习爬坑记录4:ios8中的搜索栏,使用UISearchController

来源:互联网 发布:python 类型转换 编辑:程序博客网 时间:2024/06/05 04:09

问题提出,今天在看《Begining iOS 7 Development Exploring the iOS SDK》第八章为表格添加搜索栏的时候出现的,书中说使用如下代码创建:

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

我的编译器,Xcode 6.1 发警告, 'UISearchDisplayController' is deprecated: first deprecated in iOS 8.0 - UISearchDisplayController has been replaced with UISearchController

原来在ios 8的API中,被换成了UISearchController,但上面的例子在iOS 8.1内核的模拟器上可以运行 ,于是我有了一个疑问,这个问题我再cocoachina的论坛上提了,希望明白的人能指导下,链接:http://www.cocoachina.com/bbs/read.php?tid=271816&page=e&#a


UISearchController的疑问,求指导   


是这样的,在ios 8之前用UISearchDisplayController创建搜索栏,在iOS 8之后用UISearchController,我想问,如果我用UISearchDisplayController创建的搜索栏,能在iOS 8系统上正常运行吗?又或者,如果我用UISearchController创建的搜索栏,能在iOS 8以下的系统正常运行吗?如果答案是否,那我要兼容iOS 7和8,该怎么样来实现搜索栏呢?谢谢 

这是个问题暂时还没得到解答,


关于UISearchController的使用,kilik52在github上上传了一个简单示例,可以参考一下,链接:https://github.com/kilik52/UISearchControllerExampleMinimal


0 0
原创粉丝点击