i'm using the following code to display a UISearchBar
searchController = UISearchController(searchResultsController: resultsTableViewController)
searchController?.searchResultsUpdater = self
searchController?.searchBar.sizeToFit()
searchController?.searchBar.backgroundColor = UIColor.whiteColor()
searchController?.searchBar.searchBarStyle = UISearchBarStyle.Minimal
self.tableView?.tableHeaderView = searchController?.searchBar
searchController?.delegate = self
searchController?.dimsBackgroundDuringPresentation = false
searchController?.searchBar.delegate = self
definesPresentationContext = true
my problem is when i'm entering search mode the view goes fullscreen and i can see the content of tableview overlaps with UISearchBar is this a bug any solution to this problem?
see screenshot
my solution
func willPresentSearchController(searchController: UISearchController) {
topBarView = UIView(frame: CGRectMake(0.0, 0.0, self.view.frame.size.width, 20.0))
topBarView?.backgroundColor = UIColor.whiteColor()
AppDelegate.sharedAppDelegate().window?.rootViewController?.view.addSubview(topBarView!)
}
func willDismissSearchController(searchController: UISearchController) {
topBarView?.removeFromSuperview()
}