ios - 关闭 ViewController 后,我的 View 保持在 iOS 7 中以前的 View Controller 方向

标签 ios iphone ios7 navigation uiinterfaceorientation

因为我正在使用 iOS 应用程序仅支持 Portrait Orientation .
但我遇到了一些与方向相关的问题。

  • 我的应用只支持纵向
  • 当我的 parent P1.查看使用导航推送它处于纵向模式,这很好。现在从 P1.查看我正在查看我的 subview C1.查看
  • 现在我在childview C1.查看从那里使用委托(delegate)我打电话

    -(void)imagePickerController:(UIImagePickerController *)picker
    [self.delegate openCamera] ;//从 C1.view 调用
    -(void)openCamera   //declared in P1.view
        {
            UIImagePickerController *picker = [[UIImagePickerController alloc] init];
            picker.delegate = self;
            picker.allowsEditing = NO;
            picker.sourceType = UIImagePickerControllerSourceTypeCamera;>             
            [self presentModalViewController:picker animated:YES];
        }
    
  • 现在,当我在横向模式下拍摄照片并关闭它时
    presentModalViewController 我的 View 出现在 Landscapmode 而不是 Portrait
    模式。
        - (BOOL)shouldAutorotate {
            return YES;
        }
        - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
         return (interfaceOrientation == UIInterfaceOrientationPortrait ||
                interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
        }
    
        - (NSUInteger)supportedInterfaceOrientations {    
            return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
        }
        - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
            return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
        }
    

  • 此方法在 View Controller (P1 和 C1)中定义,并且在模型 View 关闭时也被调用,但是我的 View Controller 仍然在景观中,这不应该发生。

    此代码在 iOS6 中运行良好,但在 iOS7 中运行良好

    最佳答案

    我认为 preferredInterfaceOrientationForPresentation不应该返回位掩码。你可以试试:
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationPortrait; }

    关于ios - 关闭 ViewController 后,我的 View 保持在 iOS 7 中以前的 View Controller 方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24424852/

    相关文章:

    ios - Mac OS X Lion/Mountain Lion 缓存未命中分析

    ios - deleteObject 在 Realm 中不起作用

    iphone - iOS7 应用程序提交 - 只有 2x(视网膜)图像?

    ios - 在 Cocoa 中解析 mailto URL 的现成解决方案?

    iphone - 从 paypal sdk 2.0.1 获取 Bun Now 按钮

    ios - 使用全局 Tint 颜色作为 UINavigationBars backgroundColor

    ios - localizedString ForKey :value:table ignores Base localization

    iphone - fbDidLogin 的问题从未调用过 iOS

    ios - Imagemagick降低PNG深度

    ios - FlexBox 不适用于 iPhone 6