当UISearchController处于活动状态时,iOS 9 searchBar从表标题视图中消失 [英] iOS 9 searchBar disappears from table header view when UISearchController is active
问题描述
结构:
View1(单击一个按钮)->模态显示(MyModalView:UITableViewController)
View1 (click a button) -> present modally (MyModalView: UITableViewController)
MyModalView嵌入了UISearchController. UISearchController的searchBar放在MyModalView.tableView.tableHeaderView中.
MyModalView has UISearchController embedded. The searchBar of UISearchController is placed in MyModalView.tableView.tableHeaderView.
自iOS 8.0起,它一直运行良好.但是在iOS 9上,当UISearchController处于活动状态时,searchBar消失.请在下面看这些图片
It's been working fine since iOS 8.0. However on iOS 9, the searchBar disappear when the UISearchController is active. Please take a look at theses pictures below
模式视图:
在iOS 8上处于活动状态的UISearchController:
UISearchController active on iOS 8:
在iOS 9上有效的UISearchController:
UISearchController active on iOS 9:
非常标准的代码:
override func viewDidLoad() {
super.viewDidLoad()
// Dynamically create a search controller using anonymous function
self.resultSearchController = ({
let controller = UISearchController(searchResultsController: nil)
controller.searchResultsUpdater = self
controller.dimsBackgroundDuringPresentation = false
controller.searchBar.sizeToFit()
controller.searchBar.delegate = self
self.tableView.tableHeaderView = controller.searchBar
return controller
})()
// Auto sizing row & cell height
self.tableView.estimatedRowHeight = 130
self.tableView.rowHeight = UITableViewAutomaticDimension
self.definesPresentationContext = true
// No footer for better presentation
self.tableView.tableFooterView = UIView.init(frame: CGRectZero)
}
此问题也发生在iOS 9.1 beta中...
This issue also happens in iOS 9.1 beta...
任何想法/指针都将不胜感激
Any idea / pointer would be deeply appreciated
干杯.
推荐答案
似乎我们每个人都遇到了相同的问题,但是解决方法不同.但是,没有建议的答案对我有用:(.尽管如此,感谢您的宝贵时间.
It seems all of us got the same problem but they were solved in different ways. However none of the suggested answers worked for me :(. Nevertheless thank you all for your time.
我有解决问题的解决方案.使用接口构建器,在情节提要中将我的(MyModalView:UITableViewController)的不透明条下的扩展边缘-下""设置为true.
I got a solution that solved my problem. It is setting Extend Edges - Under Opaque Bars of my (MyModalView: UITableViewController) to true in the Storyboard using Interface Builder.
总结:
MyModalView:UITableViewController,在使用Interface Builder的情节提要中具有
MyModalView: UITableViewController, in Storyboard using Interface Builder has
延伸边缘: -在顶部栏下打勾 -在底部栏下打勾 -在不透明条下面打勾
Extend Edges: - Under Top Bars ticked - Under Bottom Bars ticked - Under Opaque Bars ticked
这篇关于当UISearchController处于活动状态时,iOS 9 searchBar从表标题视图中消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!