我希望在所有设备和所有方向上始终在弹出窗口中显示视图控制器。我试图通过采用UIPopoverPresentationControllerDelegate并设置sourceView和sourceRect来实现这一点。故事板中的segue被配置为作为Popover segue的礼物。这是非常好的工作所有的设备和方向,除了iPhone 6+在景观。在这种情况下,视图控制器在表单中从屏幕底部滑行。我怎样才能防止它总是出现在弹出框中呢?
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
}发布于 2015-05-27 13:35:19
实现新的( iOS 8.3) adaptivePresentationStyleForPresentationController:traitCollection:方法的UIAdaptivePresentationControllerDelegate
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller traitCollection:(UITraitCollection *)traitCollection {
// This method is called in iOS 8.3 or later regardless of trait collection, in which case use the original presentation style (UIModalPresentationNone signals no adaptation)
return UIModalPresentationNone;
}UIModalPresentationNone告诉演示控制器使用原始的演示样式,在您的情况下,这种样式将显示一个弹出窗口。
https://stackoverflow.com/questions/29884416
复制相似问题