iOS 9 searchBar disappears from table header view when UISearchController is active

后端 未结 13 1287
無奈伤痛
無奈伤痛 2020-12-07 20:37

The structure:

View1 (click a button) -> present modally (MyModalView: UITableViewController)

MyModalView has UISearchController embedded. The searchBar of U

13条回答
  •  南方客
    南方客 (楼主)
    2020-12-07 21:19

    sc.hidesNavigationBarDuringPresentation = false
    

    does the trick for me

    lazy var searchController:UISearchController = {
            let sc = UISearchController(searchResultsController: nil)
            sc.searchResultsUpdater = self
            sc.obscuresBackgroundDuringPresentation = false
            sc.searchBar.placeholder = "Search"
            sc.hidesNavigationBarDuringPresentation = false
            return sc
        }()
    

提交回复
热议问题