
本文是小编为大家收集整理的关于UIModalPresentationPopover for iPhone 6 Plus in landscape doesn't display popover的处理方法,想解了UIModalPresentationPopover for iPhone 6 Plus in landscape doesn't display popover的问题怎么解决?UIModalPresentationPopover for iPhone 6 Plus in landscape doesn't display popover问题的解决办法?那么可以参考本文帮助大家快速定位并解决问题。
问题描述
我希望始终在所有设备和所有方向的弹出窗口中显示一个 ViewController.我试图通过采用 UIPopoverPresentationControllerDelegate 并设置 sourceView 和 sourceRect 来实现这一点.
这对所有设备和方向都非常有效,横向的 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 }
所有设备均在 iOS 8.2 或更高版本
推荐答案
实现UIAdaptivePresentationControllerDelegate的新adaptivePresentationStyleForPresentationController:traitCollection:方法:
- (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 告诉演示控制器使用原始演示样式,在您的情况下将显示一个弹出框.