UISearchDisplayController results table overlaps UISearchbar in iOS 8

625 views Asked by At

I added UISearch Bar and UISearchDisplayController to UINavigationController with MapView. When I start typing in the search bar, results table view overlaps search bar on iOS 8. On iOS 7 it's working without any issues: UISearchBar moves on top of navigation bar and stays there on results table view. On iOS 8 UISearchBar does not move on top of navigation bar and results table view overlaps it.

I tried to add searchBar as a subview to searchResultsTableView and still no luck

func searchDisplayControllerDidEndSearch(controller: UISearchDisplayController) {
    let searchBar = controller.searchBar
    let superView = searchBar.superview
    if let tableSuperView = superView as? UITableView {
    } else {
        searchBar.removeFromSuperview()
        controller.searchResultsTableView.addSubview(searchBar)

    }

}

It's doing that only in detail view of UISplitViewController.

Ended up doing this:

func searchDisplayControllerWillBeginSearch(controller: UISearchDisplayController) {
    self.navigationController?.setNavigationBarHidden(true, animated: true)
}

func searchDisplayControllerWillEndSearch(controller: UISearchDisplayController) {
    self.navigationController?.setNavigationBarHidden(false, animated: true)
}
0

There are 0 answers