我正在使用 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 的首选接口(interface)方向ForPresentation 方法的结果?
Best Answer-推荐答案 strong>
我在 Apple 论坛上回答了这个问题,但万一有人偶然发现了 Google 的这个帖子……
预计这不会起作用。据我所知,在演示时处理方向调整的逻辑只存在于用于实现默认演示样式的私有(private) UIPresentationController 子类中。
顺便说一句,自定义呈现 View Controller 的 -supportedInterfaceOrientations 方法通常会被忽略,除非您在呈现 Controller 子类中覆盖 -shouldRemovePresentersView。
关于ios - 自定义模态表示忽略了 preferredInterfaceOrientationForPresentation,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/26689426/
|