ios - 横向 iPhone 6 Plus 的 UIModalPresentationPopover 不显示弹出窗口

标签 ios iphone ios8 iphone-6-plus uimodalpresentationstyle

我想始终在所有设备和所有方向上的弹出窗口中显示一个 ViewController。我试图通过采用 UIPopoverPresentationControllerDelegate 并设置 sourceViewsourceRect 来实现这一点。

这适用于所有设备和方向,除了横向的 iPhone 6 Plus。在这种情况下, View Controller 会在表单中从屏幕底部向上滑动。我怎样才能防止它始终出现在弹出窗口中?

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 告诉呈现 Controller 使用原始呈现样式,在您的情况下将显示弹出窗口。

关于ios - 横向 iPhone 6 Plus 的 UIModalPresentationPopover 不显示弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30378249/

相关文章:

iphone - 导航问题

iphone - 根据 iOS 应用程序中的设置重新加载 UITableView

iphone - 您如何确定 future 转型的框架?更新 : More elegant way?

ios - 如何自动更新由 MDM 管理的应用程序?

xcode - 无法在 iOS8beta5 中使用 UIWebView 打开 PDF 文件

ios - 在 UIsplitView 中更改主按钮的标题

javascript - 30 分钟后 iPad AJAX 调用错误

ios - Skobbler iOS SDK : Why are there borders around my map annotations?

ios - 核心动画 : Flipp a view

ios - iOS 中的 GPUImage 二值化