This is how I setup my UIsearchController
private func setupSearchController() {
let searchResultsController = storyboard!.instantiateViewControllerWithIdentifier(DBSearchOptionControllerIdentifier) as! DBSearchOptionController
searchController = UISearchController(searchResultsController: searchResultsController)
let frame = searchController.searchBar.frame
searchController.searchBar.frame = CGRectMake(0, 50, view.bounds.size.width, 44.0)
searchController.searchResultsUpdater = self
view.addSubview(searchController.searchBar)
searchController.searchBar.text = "mmm"
view.bringSubviewToFront(searchController.searchBar)
searchController.searchBar.bringSubviewToFront(view)
}
This is how it looks after I initialise UISearchController
:
This is how it looks when I start typing in UISearchBar:
Why my search bar disappear?
This is very interesting, because now when I stop the app, you can see, that it is there, indeed:-) So why it is not visible?
I made some testing and found a way:
UISearchBar definitely must be inserted into wrapper:
@IBOutlet weak var wrapperView: UIView!
...
wrapperView.addSubview(searchController.searchBar)
The result is following:
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