状态栏在搜索时消失

时间:2016-11-10 23:00:15

标签: ios swift uitableview search statusbar

我的状态栏有问题。

当我按下我的搜索栏时,它就消失了,看看例子:

状态栏在按下搜索栏之前正常显示: Status bar shows normally before search bar pressed.

状态栏不显示,只是消失在视野之外: Status bar does not show and just disappears out of view

非常感谢! :)

这是我的searchController设置:

 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 = "חפש ברים"

}

1 个答案:

答案 0 :(得分:3)

尝试此设置:

searchController.hidesNavigationBarDuringPresentation = false

并覆盖此功能(Swift 2):

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