Newbie Questions Newbie Questions - 1 month ago 6
iOS Question

Status Bar disappearing When Searching

I have a problem with my status bar .

it disappears as soon as i press on my search bar,Look at the examples :

Status bar shows normally before search bar pressed:
Status bar shows normally before search bar pressed.

Status bar does not show and just disappears out of view:
Status bar does not show and just disappears out of view

Thanks ahead ! :)

here is my searchController setup :

override func viewDidLoad() {
super.viewDidLoad()

definesPresentationContext = true
self.resultsController.tableView.dataSource = self
self.resultsController.tableView.delegate = self
self.searchController.hidesNavigationBarDuringPresentation = false
self.searchController = UISearchController(searchResultsController: self.resultsController)
self.tableView.tableHeaderView = self.searchController.searchBar
self.searchController.searchResultsUpdater = self
self.searchController.dimsBackgroundDuringPresentation = true
self.searchController.searchBar.sizeToFit()
self.searchController.searchBar.barTintColor = UIColor.blackColor()
self.searchController.searchBar.endEditing(true)
self.searchController.searchBar.placeholder = "חפש ברים"

}

Answer

Try this setting:

searchController.hidesNavigationBarDuringPresentation = false

And override this function (Swift 2):

override func preferredStatusBarStyle() -> UIStatusBarStyle { 
    return .LightContent 
}