我想始终在所有设备和所有方向的弹出窗口中显示一个视图控制器。我试图通过采用UIPopoverPresentationControllerDelegate
and 设置sourceView
and来实现这一点sourceRect
。故事板中的 segue 被配置为 Present As Popover segue。这适用于所有设备和方向,除了 iPhone 6 Plus 横向。在这种情况下,视图控制器会在表单中从屏幕底部向上滑动。我怎样才能防止它总是出现在弹出窗口中?
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
let popoverPresentationController = segue.destinationViewController.popoverPresentationController
popoverPresentationController?.delegate = self
popoverPresentationController?.sourceView = self.titleLabel!.superview
popoverPresentationController?.sourceRect = self.titleLabel!.frame
}
func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle {
return UIModalPresentationStyle.None
}