UISearchController makes the controller black

社会主义新天地 提交于 2019-11-30 19:02:17

Try self.definesPresentationContext = YES; instead of NO. Here is how I setup my UISearchController, but I haven't done it this way in a UITabBarController before.

func setupSearchController() {
    let resultsController = UIStoryboard(name: "ATPageTableViewController", bundle: nil).instantiateViewControllerWithIdentifier("ATPageTableSearchResultsViewController") as! ATPageTableSearchResultsViewController
    searchController = UISearchController(searchResultsController: resultsController)
    searchController.delegate = self
    resultsController.delegate = self
    resultsController.cellIdentifier = ATDataSetItemTableViewCellIdentifier;
    resultsController.table = self.table!
    searchController.searchBar.sizeToFit()
    self.tableView.tableHeaderView = searchController.searchBar
    searchController.searchResultsUpdater = self
    searchController.searchBar.delegate = self
    definesPresentationContext = true

}

Write the below code in viewDidLoad mehtod.

self.definesPresentationContext = true

searchController.searchResultsUpdater = self

searchController.searchBar.delegate = self

searchController.dimsBackgroundDuringPresentation = false searchController.definesPresentationContext = true

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!