Popover 在横向模式下显示时占据整个屏幕,但在纵向模式下它可以正常工作。此外,当我在横向模式下单击弹出窗口外时,它不会消失。
我通过 Storyboard连接了弹出窗口。在 popoverviewcontroller 中,我放置了一个包含按钮的 View 。 popoverviewcontroller的viewdidload()的代码是:
override func viewDidLoad() {
super.viewDidLoad()
self.preferredContentSize = popoverView.frame.size
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
肖像:
景观:
最佳答案
@Jake2Finn 的回答适用于 Swift 4.0。
特别需要 trait 参数来修复景观问题:
traitCollection: UITraitCollection
没有它,功能自适应...仅适用于纵向。
关于ios - swift - 弹出窗口在横向模式下显示不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38572681/