ios - 自定义模态表示忽略了 preferredInterfaceOrientationForPresentation
<p><p>我正在使用 iOS 8 的 UIPresentationController 编写自定义模式演示。呈现的 Controller 具有首选界面方向 <code>UIInterfaceOrientationLandscapeLeft</code>。</p>
<p>在使用 UIPresentationController 呈现此 Controller 时,它会以纵向显示,忽略呈现的 Controller 的 preferredInterfaceOrientationForPresentation 方法的结果。</p>
<p><strong>呈现 ViewController </strong></p>
<pre><code>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)
}
</code></pre>
<p><strong>呈现的 ViewController </strong></p>
<pre><code>override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
return .LandscapeLeft
}
</code></pre>
<p>是否可以让 UIPresentationController 考虑所呈现 Controller 的首选接口(interface)方向ForPresentation 方法的结果?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>我在 Apple 论坛上回答了这个问题,但万一有人偶然发现了 Google 的这个帖子……</p>
<p>预计这不会起作用。据我所知,在演示时处理方向调整的逻辑只存在于用于实现默认演示样式的私有(private) UIPresentationController 子类中。</p>
<p>顺便说一句,自定义呈现 ViewController 的 -supportedInterfaceOrientations 方法通常会被忽略,除非您在呈现 Controller 子类中覆盖 -shouldRemovePresentersView。</p></p>
<p style="font-size: 20px;">关于ios - 自定义模态表示忽略了 preferredInterfaceOrientationForPresentation,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/26689426/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/26689426/
</a>
</p>
页:
[1]