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

2019-09-22 11:43发布

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条回答
太酷不给撩
2楼-- · 2019-09-22 12:28


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

查看更多
登录 后发表回答