【问题标题】:Custom modal presentation ignores preferredInterfaceOrientationForPresentation自定义模态表示忽略了 preferredInterfaceOrientationForPresentation
【发布时间】:2014-11-01 12:43:36
【问题描述】:

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

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

呈现视图控制器

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)
}

呈现的视图控制器

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

是否可以让 UIPresentationController 考虑所呈现控制器的首选接口方向ForPresentation 方法的结果?

【问题讨论】:

    标签: ios ios8 uikit uikit-transitions


    【解决方案1】:

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

    预计这不会起作用。据我所知,在演示时处理方向调整的逻辑只存在于用于实现默认演示样式的私有 UIPresentationController 子类中。

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

    【讨论】:

    猜你喜欢
    • 2020-11-01
    • 2012-04-30
    • 1970-01-01
    • 2018-10-04
    • 2021-03-22
    • 1970-01-01
    • 2020-01-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多