Azuan
Azuan

Reputation: 928

UISearchBar doesn't dismiss on push segue

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

Upvotes: 1

Views: 1651

Answers (1)

Leo
Leo

Reputation: 24714

Manual stop UISearchController in prepareForSegue

searchController.active = false

Or add this in viewDidLoad

   searchController.definesPresentationContext = true

Upvotes: 11

Related Questions