2

I AM NOT USING STORYBOARD SEGUES.

When I use UISearchController to have a search bar at the top of my table view, I get extremely strange behavior. Is there documentation on how I'm supposed to handle the search bar when a view dismisses? When I switch to a new view controller via an animation or push one on a nav stack, the bar is stuck in its spot until I hit the "Cancel" button.

See a video of what's happening in this short clip:

https://www.youtube.com/watch?v=6G7xFMENm_o&feature=youtu.be

This is the code, in the view controller, that sets up search bar:

var s: UISearchController!
private func configureSearching() {
    s = UISearchController(searchResultsController: nil)
    s.searchResultsUpdater = self
    s.dimsBackgroundDuringPresentation = false
    s.searchBar.searchBarStyle = .Minimal
    s.hidesNavigationBarDuringPresentation = false
    tableView.tableHeaderView = s.searchBar
    s.searchBar.sizeToFit()
}
Stefan Arambasich
  • 2,231
  • 2
  • 19
  • 24

1 Answers1

0

you should add the following line in viewDidLoad

self.definesPresentationContext = true
paulvs
  • 11,963
  • 3
  • 41
  • 66
Praveen Gowda I V
  • 9,569
  • 4
  • 41
  • 49