1

I'm trying out UISearchController for iOS 8 right now. When I click the cell, it will push the segue and show another view controller. However, the search controller/bar is still there on the next controller. Also, I notice that the status bar background is white, while it should be grey as the searchBar background color is grey. Is there anything that I miss?

This is the codes that I used to initialise the search controller

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.

    searchController = UISearchController(searchResultsController: nil)
    searchController.searchResultsUpdater = self
    searchController.hidesNavigationBarDuringPresentation = false
    searchController.dimsBackgroundDuringPresentation = false
    searchController.searchBar.sizeToFit()
    tableView.tableHeaderView = searchController.searchBar
}

Screenshot:

enter image description here

Azuan
  • 878
  • 2
  • 13
  • 33
  • possible duplicate of [UISearchController persisting after segue](http://stackoverflow.com/questions/29472011/uisearchcontroller-persisting-after-segue) – Azuan May 12 '15 at 08:54

1 Answers1

11

Manual stop UISearchController in prepareForSegue

searchController.active = false

Or add this in viewDidLoad

   searchController.definesPresentationContext = true
Leo
  • 24,596
  • 11
  • 71
  • 92
  • Actually I forgot to set definesPresentationContext = true. Now not sure how can I close this question and mark as duplicate. Someone asked the same question too before – Azuan May 12 '15 at 07:00