ios - UISearchBar 不会在推送时关闭

标签 ios swift

我现在正在试用适用于 iOS 8 的 UISearchController。当我单击该单元格时,它将插入 segue 并显示另一个 View Controller 。但是,搜索 Controller /栏仍然存在于下一个 Controller 上。另外,我注意到状态栏背景是白色的,而它应该是灰色的,因为 searchBar 背景颜色是灰色的。有什么我想念的吗?

这是我用来初始化搜索 Controller 的代码

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.

    searchController = UISearchController(searchResultsController: nil)
    searchController.searchResultsUpdater = self
    searchController.hidesNavigationBarDuringPresentation = false
    searchController.dimsBackgroundDuringPresentation = false
    searchController.searchBar.sizeToFit()
    tableView.tableHeaderView = searchController.searchBar
}

截图:

enter image description here

最佳答案

prepareForSegue中手动停止UISearchController

searchController.active = false

或者在viewDidLoad中添加这个

   searchController.definesPresentationContext = true

关于ios - UISearchBar 不会在推送时关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30183747/

相关文章:

ios - 如何在 swift 接收推送通知时调用服务器?

swift - Swift 中 'is' 和 'as' 关键字的区别

javascript - 在ios中使用touchmove获取$(document).scrollTop()

ios - 如何通过 CKFetchNotificationChangesOperation 避免低效的网络数据使用?

ios - 在可重复使用的单元格中显示下载进度

ios - 通过转换保存 GameScene 的状态

swift - 如何使用多个 View Controller 使用 Firebase 身份验证?

ios - 设置中的 iCloud iCon 仅在 iOS 中显示为白色

ios - 每次 UITextField 文本属性在 RxSwift 中更改时如何获得信号

ios - 如何对从服务器接收响应的代码进行单元测试