ios - 自定义模式呈现忽略 preferredInterfaceOrientationForPresentation

标签 ios ios8 uikit uikit-transitions

我正在使用 iOS 8 的 UIPresentationController 编写自定义模式演示文稿。呈现的 Controller 具有首选界面方向 UIInterfaceOrientationLandscapeLeft

在使用 UIPresentationController 呈现此 Controller 时,它以纵向显示,忽略呈现的 Controller 的 preferredInterfaceOrientationForPresentation 方法的结果。

呈现 View Controller

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    if let controller = segue.destinationViewController as? UIViewController {
        controller.modalPresentationStyle = .Custom
        controller.transitioningDelegate = self
    }
}

func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
    return nil
}

func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
    return nil
}

func presentationControllerForPresentedViewController(presented: UIViewController,
    presentingViewController presenting: UIViewController!,
    sourceViewController source: UIViewController) -> UIPresentationController? {
        return UIPresentationController(presentedViewController: presented, presentingViewController: presenting)
}

呈现 View Controller

override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
    return .LandscapeLeft
}

是否可以让 UIPresentationController 考虑呈现的 Controller 的 preferredInterfaceOrientationForPresentation 方法的结果?

最佳答案

我在 Apple 论坛上回答了这个问题,但以防万一有人偶然发现来自 Google 的这个帖子..

这预计不会奏效。据我所知,在呈现时处理方向调整的逻辑仅存在于用于实现默认呈现样式的私有(private) UIPresentationController 子类中。

顺便说一句,自定义呈现 View Controller 的 -supportedInterfaceOrientations 方法通常会被忽略,除非您在呈现 Controller 子类中覆盖 -shouldRemovePresentersView。

关于ios - 自定义模式呈现忽略 preferredInterfaceOrientationForPresentation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26689426/

相关文章:

objective-c - [CALayer drawInContext] 重影

ios - SQL 查询由于某种原因不工作

ios - 应用程序名称未出现在权限请求警报中

ios - NSUserDefaults 在 iOS 8 中不可靠

ios - 更改 UISegmentedControl 中特定段的标题文本颜色?

iphone - 为什么加载 View Controller 时没有调用我的 initWithNib 方法?

iphone - 如何无条件地将绿色添加图标放在插入行上

ios - 带有图像和标题的 UISegmentedControl

ios - SwiftyJson 添加到对象/数组的末尾

ios - 支持 iPhone 6 和 iPhone 6+,针对 iPad 纵向和横向使用不同的启动/启动屏幕图像