i'm targeting my app should run on both iOS 7 & iOS 8. Since UISearchDisplayController is deprecated in iOS 8, i used UISearchController for iOS 8. But it's not working in iOS 7. If i use UISearchDisplayController then it will work in iOS 7. But what is best way to implement the search controller for both platform ? In iOS 8, i implemented search controller like below -
override func viewDidLoad() {
super.viewDidLoad()
// Search Controller Setup
searchController = UISearchController(searchResultsController: nil)
searchController.searchBar.delegate = self
searchController.searchResultsUpdater = self
searchController.dimsBackgroundDuringPresentation = false
searchController.searchBar.placeholder = "ব্র্যান্ড/সংস্থা/দোকান খুঁজুন"
// Make sure the that the search bar is visible within the navigation bar.
searchController.searchBar.sizeToFit()
tableView.tableHeaderView = searchController.searchBar
definesPresentationContext = true
}
and for iOS 7 in SWIFT, how can i implement UISearchDisplayController programatically like above to make sure that search bar is visible within the navigation bar ?
Use the ios7 way. Even if it deprecates. Or you will have to make two code, one for handle iOS7 and the other one for iOS8. IF you are targetting iOS 7, Xcode won't show you warnings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With