Can I use a UISearchController with a storyboard?

Is there a way to use the UISearchController in a way that allows me to storyboard the UISearchBar ? I have a storyboard user interface with a navigation bar that contains my search bar. It would be great if I could save it that way, because setting up the software programmatically would be really inconvenient. I know that the old UISearchDisplayController can be uploaded. Is there a way to do something like this with a UISearchController?

+1
source share
2 answers

No, unfortunately, this is not yet possible (iOS 10 and earlier). See this sample code, which has been updated for iOS 10 , which shows how to programmatically configure UISearchController.

0
source

Add a UIView to your layout. This will be the container for your UISearchBar . Then programmatically create an instance of UISearchController, and then add the search string to the container:

 let searchController = UISearchController(searchResultsController: searchResultsController) searchBarContainer.addSubview(searchController.searchBar) 
0
source

All Articles