【问题标题】:iOS 6 controlling autorotation of view controllers behind UIImagePickerControlleriOS 6 控制 UIImagePickerController 后面的视图控制器的自动旋转
【发布时间】:2013-08-29 10:17:40
【问题描述】:

我的 iPad 应用程序有一个名为 MainViewControllerUIViewController,它显示了一个名为 ModalViewController 的模态页面表 UIViewControllerModalViewController 然后显示UIImagePickerController

这里是 MainViewController.m

@implementation MainViewController {

...

- (BOOL)shouldAutorotate
{
    return YES;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeRight;
}

...

}

所以它会旋转到任一横向方向,当出现ModalViewController 时,它也会正确旋转。

但是,当 UIImagePickerController 出现时,它允许旋转到横向或纵向,这允许 MainViewControllerModalViewController 旋转到不需要的方向。

UIImagePickerController 出现在屏幕上时,如何防止MainViewControllerModalViewController 旋转?

【问题讨论】:

    标签: ios ios6 uiviewcontroller uiimagepickercontroller


    【解决方案1】:

    这与Stop a modal UIViewController from rotating 这里问的问题相同吗?如果你最后使用UINavigationController,你可以继承它并控制旋转机制

    【讨论】:

    • 不,这不是同一个问题。我已经对容器视图控制器进行了子类化,以便将旋转委托给最顶层的视图控制器。问题是我希望相机模态旋转到任何方向,但我需要它后面的控制器不旋转,或者至少在相机模态被关闭时以校正方向结束。
    • 哦,好的,我明白了。然后,如果您仍然希望允许 UIImagePicker 控制器旋转,但您不希望底层控制器这样做,您是否考虑过为这些旋转图层?如果方向是您打算支持的方向,您可以检查旋转回调,如果不是这种情况,您可以旋转图层,以便最终它仍然按照您的意愿“显示”。
    • 这是一种“正确”的做事方式吗?我担心状态栏不一定在正确的位置,self.view.frame 不会像预期的那样。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-15
    • 1970-01-01
    相关资源
    最近更新 更多