Insert a UISearchBar in IOS 8, Xcode 6 [closed]

我们两清 提交于 2019-12-13 10:14:14

问题


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

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?


回答1:



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 
}

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

Best regards,
Gabriel Tomitsuka



来源:https://stackoverflow.com/questions/27632093/insert-a-uisearchbar-in-ios-8-xcode-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!