在IOS 8,Xcode 6中插入UISearchBar [英] Insert a UISearchBar in IOS 8, Xcode 6

查看:182
本文介绍了在IOS 8,Xcode 6中插入UISearchBar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实施 UISearchBar 的最有效方法是什么?

What is the best most efficient way to implement a UISearchBar?

我在互联网上查看,并且所有教程都适用于 ios 7 版本,并且许多方法在 ios 8 中已弃用。有人可以提供一个库,或者如何在xcode中为 ios 8 实现 searchBar 的示例?

I check all over the internet, and all the tutorials are for the ios 7 version, and a lot of the methods are deprecated in ios 8. Can someone please provide a library, or a sample of how to implement a searchBar in xcode for ios 8?

推荐答案


我必须做几个月前做的事情。所以,我在GitHub上找到了这个: https://github.com/dempseyatgithub/Sample-UISearchController
下载/克隆它,您将能够看到如何将UISearchController与UITableView和UICollectionView一起使用。它具有从UISearchDisplayController升级到UISearchController所需的一切。 UISearchController文档也非常有用。
如果您还需要支持iOS 7(我个人推荐的内容,如果您真的要将应用程序部署到App Store),请执行以下操作:


I had to do the same you are doing a few months ago. So, I found this on GitHub: https://github.com/dempseyatgithub/Sample-UISearchController
Download/clone it and you'll be able to see how to use UISearchController with UITableView and UICollectionView. It has everything you need to upgrade from UISearchDisplayController to UISearchController. The UISearchController documentation is also really helpful.
If you also need to support iOS 7(something I personally recommend if you are really about to deploy your app to the App Store) do this:

if([UISearchController class]){
//Create an UISearchController and add it to your UITableViewController
}else{
//Create an UISearchDisplayController and add it to your UITableViewController 
}

注意:你将拥有如果你想支持两个版本的iOS,以编程方式完成所有事情。

Note: You'll have to do everything programatically if you want to support both versions of iOS.

祝你好运,

Gabriel Tomitsuka

Best regards,
Gabriel Tomitsuka

这篇关于在IOS 8,Xcode 6中插入UISearchBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆