<i id='hiRWp'><tr id='hiRWp'><dt id='hiRWp'><q id='hiRWp'><span id='hiRWp'><b id='hiRWp'><form id='hiRWp'><ins id='hiRWp'></ins><ul id='hiRWp'></ul><sub id='hiRWp'></sub></form><legend id='hiRWp'></legend><bdo id='hiRWp'><pre id='hiRWp'><center id='hiRWp'></center></pre></bdo></b><th id='hiRWp'></th></span></q></dt></tr></i><div id='hiRWp'><tfoot id='hiRWp'></tfoot><dl id='hiRWp'><fieldset id='hiRWp'></fieldset></dl></div>

    • <bdo id='hiRWp'></bdo><ul id='hiRWp'></ul>

      <small id='hiRWp'></small><noframes id='hiRWp'>

      <tfoot id='hiRWp'></tfoot>
      1. <legend id='hiRWp'><style id='hiRWp'><dir id='hiRWp'><q id='hiRWp'></q></dir></style></legend>

        iOS 6 - 某些视图的导航控制器横向旋转,而其他视图仅纵向

        时间:2023-05-16
          <tbody id='oETZW'></tbody>
        • <bdo id='oETZW'></bdo><ul id='oETZW'></ul>

                1. <small id='oETZW'></small><noframes id='oETZW'>

                  <tfoot id='oETZW'></tfoot>
                2. <legend id='oETZW'><style id='oETZW'><dir id='oETZW'><q id='oETZW'></q></dir></style></legend>
                  <i id='oETZW'><tr id='oETZW'><dt id='oETZW'><q id='oETZW'><span id='oETZW'><b id='oETZW'><form id='oETZW'><ins id='oETZW'></ins><ul id='oETZW'></ul><sub id='oETZW'></sub></form><legend id='oETZW'></legend><bdo id='oETZW'><pre id='oETZW'><center id='oETZW'></center></pre></bdo></b><th id='oETZW'></th></span></q></dt></tr></i><div id='oETZW'><tfoot id='oETZW'></tfoot><dl id='oETZW'><fieldset id='oETZW'></fieldset></dl></div>
                  本文介绍了iOS 6 - 某些视图的导航控制器横向旋转,而其他视图仅纵向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我正在构建一个仅适用于主要视图(正常和倒置)的纵向应用程序.我已经在项目设置/Plist 中设置了这个设置,一切正常.但是,我有一些模态视图可以执行显示图像/视频之类的操作,我希望它们能够旋转到所有方向.

                  I am building an app that will be Portrait only for the main views (Both normal and upside down). I have set this setting in the Project Settings/Plist and all works fine. However, I have a few modal views that do things like display images/videos, and I want them to be able to rotate to ALL orientations.

                  我尝试为 UINavigationController 添加一个类别,但没有成功.我还向调用模态的 viewController 添加了以下代码:

                  I tried adding a category for UINavigationController but no luck. I have also added to the viewController that calls the modal the below code:

                  -(BOOL)shouldAutomaticallyForwardAppearanceMethods{
                      return NO;
                  }
                  -(BOOL)shouldAutomaticallyForwardRotationMethods{
                      return NO;
                  }
                  

                  我已将以下代码添加到我希望允许所有方向的模态视图控制器中:

                  I have added the below code to the modal viewControllers that I want to allow all orientations:

                  - (BOOL)shouldAutorotate {
                      return YES;
                  }
                  
                  - (NSUInteger)supportedInterfaceOrientations {
                      return UIInterfaceOrientationMaskAll;
                  }
                  

                  我错过了什么?有什么建议吗?

                  What am I missing? Any suggestions?

                  推荐答案

                  在 iOS 6 上,旋转处理发生了变化.对于您描述的问题,有几种方法.首先,在 plist 中,启用除纵向倒置之外的所有方向.

                  On iOS 6, rotation handling has changed. For the problem you described, there are several approaches. First, in the plist, enable all orientations except portrait upside down.

                  那么您可以使用以下解决方案之一:

                  Then you could use one of the following solutions:

                  1. 使用 UINavigationController 的子类,它只允许旋转到纵向.
                  2. 为所有控制器指定它们支持的旋转.
                  3. 您可以覆盖应用程序委托中的方法.由于每当方向更改或推送新的视图控制器时都会在您的委托上调用该方法,您可以使用它来临时启用/禁用应用程序的横向显示:

                  1. Use a subclass of UINavigationController that does only allow rotation to portrait.
                  2. For all controllers specify which rotations they support.
                  3. You can override a method in your application delegate. As that method is called on your delegate whenever the orientation changes or a new view controller is pushed, you can use it to temporarily enable/disable landscape display for your app:

                  // In AppDelegate.h:
                  @property (nonatomic) BOOL portraitOnly;
                  
                  // In AppDelegate.m:
                  - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
                  {
                      return _portraitOnly ? UIInterfaceOrientationMaskPortrait : UIInterfaceOrientationMaskAllButUpsideDown;
                  }
                  
                  // to switch to portrait only:
                  ((AppDelegate *)[UIApplication sharedApplication].delegate).portraitOnly = YES;
                  
                  // to switch to allowing landscape orientations:
                  ((AppDelegate *)[UIApplication sharedApplication].delegate).portraitOnly = NO;
                  

                  这篇关于iOS 6 - 某些视图的导航控制器横向旋转,而其他视图仅纵向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:显示模态视图时使 iPhone 状态栏消失? 下一篇:模态 UIImagePickerController 被解除时的 UIView 通知?

                  相关文章

                  <i id='X842x'><tr id='X842x'><dt id='X842x'><q id='X842x'><span id='X842x'><b id='X842x'><form id='X842x'><ins id='X842x'></ins><ul id='X842x'></ul><sub id='X842x'></sub></form><legend id='X842x'></legend><bdo id='X842x'><pre id='X842x'><center id='X842x'></center></pre></bdo></b><th id='X842x'></th></span></q></dt></tr></i><div id='X842x'><tfoot id='X842x'></tfoot><dl id='X842x'><fieldset id='X842x'></fieldset></dl></div>
                  <legend id='X842x'><style id='X842x'><dir id='X842x'><q id='X842x'></q></dir></style></legend>
                  • <bdo id='X842x'></bdo><ul id='X842x'></ul>

                    <small id='X842x'></small><noframes id='X842x'>

                    1. <tfoot id='X842x'></tfoot>