I have an app with a UISearchController. This element of the UI is completely set up in code like this:
searchController = UISearchController(searchResultsController: nil)
searchController.searchResultsUpdater = self
searchController.searchBar.delegate = self
searchController.dimsBackgroundDuringPresentation = false
searchController.hidesNavigationBarDuringPresentation = false
searchController.searchBar.searchBarStyle = UISearchBarStyle.Minimal
searchController.searchBar.frame = CGRectMake(searchController.searchBar.frame.origin.x, searchController.searchBar.frame.origin.y, searchController.searchBar.frame.size.width, 44.0)
I am then adding it to my tableView's tableHeaderView
tableView.tableHeaderView = searchController.searchBar
Everything seems to be working fine, but when it's active and I select an item in my tableView, my app segues to another view controller with the search controller persisting in the view. I'm unsure as to how this is possible since the search controller should be a subview of the table view in another view controller. How can I prevent this from happening?
prepareForSegue
? – Tim QuinntableView.tableHeaderView = nil
has no effect whatsoever when I call it inprepareForSegue
. Or do you mean to nil out the entiresearchController
? I'm not sure what the best way to handle all of this would be in that case. – KiliansearchController.active
tofalse
inprepareForSegue
. – Praveen Gowda I V