我现在正在试用适用于 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
}
截图:
最佳答案
在prepareForSegue
中手动停止UISearchController
searchController.active = false
或者在viewDidLoad中添加这个
searchController.definesPresentationContext = true
关于ios - UISearchBar 不会在推送时关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30183747/