1. <i id='g5B8r'><tr id='g5B8r'><dt id='g5B8r'><q id='g5B8r'><span id='g5B8r'><b id='g5B8r'><form id='g5B8r'><ins id='g5B8r'></ins><ul id='g5B8r'></ul><sub id='g5B8r'></sub></form><legend id='g5B8r'></legend><bdo id='g5B8r'><pre id='g5B8r'><center id='g5B8r'></center></pre></bdo></b><th id='g5B8r'></th></span></q></dt></tr></i><div id='g5B8r'><tfoot id='g5B8r'></tfoot><dl id='g5B8r'><fieldset id='g5B8r'></fieldset></dl></div>
  2. <small id='g5B8r'></small><noframes id='g5B8r'>

    <legend id='g5B8r'><style id='g5B8r'><dir id='g5B8r'><q id='g5B8r'></q></dir></style></legend>
    <tfoot id='g5B8r'></tfoot>

        <bdo id='g5B8r'></bdo><ul id='g5B8r'></ul>
    1. presentViewController 在 iOS 6 中不支持方向

      时间:2023-06-13
              <bdo id='11Msm'></bdo><ul id='11Msm'></ul>

              <small id='11Msm'></small><noframes id='11Msm'>

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

                <tbody id='11Msm'></tbody>
              <tfoot id='11Msm'></tfoot>
            • <legend id='11Msm'><style id='11Msm'><dir id='11Msm'><q id='11Msm'></q></dir></style></legend>

                本文介绍了presentViewController 在 iOS 6 中不支持方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在使用此代码

                if ([self respondsToSelector:@selector(presentViewController:animated:completion:)])
                    {
                        [self presentViewController:navigationControllerCustom animated:YES completion:nil];
                    }
                    else
                    {
                        [self presentModalViewController:navigationControllerCustom animated:YES];
                    }
                

                我的应用程序有两个方向纵向和纵向倒置.此代码适用于 iOS 5.1,但方向不适用于 iOS 6

                My application has two orientation Portrait and Portrait upside down. This code works well with iOS 5.1, but orientation does not work on iOS 6

                我还在 navigationControllerCustom 类中添加了这段代码

                I have also added this code on my navigationControllerCustom class

                - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
                {
                    return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
                }
                
                -(NSUInteger)supportedInterfaceOrientations
                {
                    return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
                }
                

                请帮我解决这个问题.

                提前致谢.

                推荐答案

                你必须在你的应用程序委托中包含这个:

                You must include this in you application delegate:

                - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
                    return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
                }
                

                还要确保视图控制器都具有以下内容,对我来说可以正常工作.

                Also make sure the View Controller's both have the following, works fine for me.

                - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
                {
                    return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
                }
                
                -(NSUInteger)supportedInterfaceOrientations
                {
                    return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
                }
                

                文档还说 UINavigationController's 不会查询其顶部视图控制器以获取支持的方向,尽管开发者论坛上的苹果工程师确实这么说......似乎它没有.因此,您应该为 UINavigationController 添加一个类别,这是我使用的:

                The documentation also says that UINavigationController's doesn't query its top View Controller for orientations supported, although an Apple engineer over on the Developer Forums did say so... it seems that it does not. Therefore you should add a category for UINavigationController, this is the one I use:

                #import "UINavigationController+autorotate.h"
                
                @implementation UINavigationController (autorotate)
                
                - (NSUInteger)supportedInterfaceOrientations{
                    return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
                }
                
                @end
                

                有关 AutoRotate 如何在 iOS 6 上工作的更多信息查看此答案

                For more information how AutoRotate works on iOS 6 check out this answer

                这篇关于presentViewController 在 iOS 6 中不支持方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:导航回上一个视图控制器 下一篇:推送 UIViewController 时显示 UITabBar

                相关文章

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

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