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

  • <tfoot id='sFjkq'></tfoot>

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

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

        UINavigationController 中仅支持一个视图的横向

        时间:2023-06-12
      1. <i id='m2zpY'><tr id='m2zpY'><dt id='m2zpY'><q id='m2zpY'><span id='m2zpY'><b id='m2zpY'><form id='m2zpY'><ins id='m2zpY'></ins><ul id='m2zpY'></ul><sub id='m2zpY'></sub></form><legend id='m2zpY'></legend><bdo id='m2zpY'><pre id='m2zpY'><center id='m2zpY'></center></pre></bdo></b><th id='m2zpY'></th></span></q></dt></tr></i><div id='m2zpY'><tfoot id='m2zpY'></tfoot><dl id='m2zpY'><fieldset id='m2zpY'></fieldset></dl></div>

        <tfoot id='m2zpY'></tfoot>

            <bdo id='m2zpY'></bdo><ul id='m2zpY'></ul>

                <tbody id='m2zpY'></tbody>

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

              1. <legend id='m2zpY'><style id='m2zpY'><dir id='m2zpY'><q id='m2zpY'></q></dir></style></legend>
                  本文介绍了UINavigationController 中仅支持一个视图的横向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个导航控制器,它有几个视图控制器.我需要支持所有视图控制器的所有方向,除了一个只支持横向的特殊视图控制器.这个特殊的视图控制器出现在导航堆栈的中间.我做了很多研究,但找不到任何好的解决方案.以下是我阅读并尝试过的链接.

                  I have a navigation controller which have a few view controllers. I need to support all orientations for all view controllers except one special view controller which only supports landscape. This special view controller appears in the middle of the navigation stack. I have done quite a lot of research but couldn't find any good solution. Here are the links that I have read and tried.

                  http://www.iphonedevsdk.com/forum/iphone-sdk-development/3219-force-landscape-mode-one-view.html#post60435

                  如何将屏幕旋转为横向?

                  如何从纵向模式自动旋转到横向模式?iPhone - 只允许在一个视图控制器上横向显示http://goodliffe.blogspot.com/2009/12/iphone-forcing-uiview-to-reorientate.html

                  接下来我将尝试用 presentModalViewController 替换导航控制器,以显示特殊的视图控制器.然后我将在特殊的视图控制器内部创建一个新的导航视图控制器来推送后续的视图控制器.

                  Next I am going to try to replace navigation controller with presentModalViewController in order to display the special view controller. Then I am going to create a new navigation view controller inside the special view controller to push the subsequent view controllers.

                  如果有人有更好的想法,请告诉我.非常感谢!

                  If anyone has a better idea, please let me know. Really appreciated!

                  更新:我已经成功使用了我上面描述的方法:将 pushViewController 替换为 presentModalViewController 并创建一个新的导航控制器.

                  UPDATE: I have successfully use the method I described above: replace pushViewController with presentModalViewController and create a new navigation controller.

                  推荐答案

                  推送到导航控制器堆栈的每个视图控制器都必须支持相同的方向.这意味着不可能有一些视图控制器只支持纵向,而另一些只支持横向.换句话说,同一个导航控制器堆栈上的所有视图控制器都应该在委托中返回相同的结果:

                  Every view controller pushed onto the navigation controllers stack have to support the same orientations. This means that it is not possible to have some view controllers only supporting portrait and others only supporting landscape. In other words all view controllers on the same navigation controller stack should return the same in the delegate:

                  (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
                  

                  但是有一个简单的解决方案!这是一个从纵向到横向的示例.这是执行此操作的步骤,下面是支持它的代码.

                  But there is a simple solution to this! Here is an example for going from portrait to landscape. Here is the steps to do it and below is code to support it.

                  1. 创建一个假"视图控制器,该控制器将作为子导航控制器的根.此视图控制器应支持横向.
                  2. 创建一个 UINavigationController 的新实例,将假"视图控制器的实例添加为 root,并将横向视图控制器的实例添加为第二个视图控制器
                  3. 在父视图控制器中将 UINavigationController 实例显示为模态
                  1. Create a ‘fake’ view controller that will be root in a sub navigation controller. This view controller should support landscape.
                  2. Create a new instance of a UINavigationController, add an instance of the ‘fake’ view controller as root and an instance of your landscape view controller as second view controller
                  3. Present the UINavigationController instance as modal from the parent view controller

                  首先,使用以下代码创建一个新的视图控制器(FakeRootViewController):

                  First, create a new view controller (FakeRootViewController) with this code:

                  @interface FakeRootViewController : UIViewController
                  @property (strong, nonatomic) UINavigationController* parentNavigationController;
                  @end
                  
                  @implementation FaceRootViewController
                  @synthesize parentNavigationController;
                  // viewWillAppear is called when we touch the back button on the navigation bar
                  (void)viewWillAppear:(BOOL)animated {
                    // Remove our self from modal view though the parent view controller
                    [parentNavigationController dismissModalViewControllerAnimated:YES];
                  }
                  (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
                     return (interfaceOrientation == UIInterfaceOrientationIsLandscape(interfaceOrientation));
                  } 
                  

                  这里是呈现您希望在横向模式下显示的视图控制器的代码:

                  Here is the code to present the view controller that you wish to show in landscape mode:

                  FakeRootViewController* fakeRootViewController = [[FakeRootViewController alloc] init];[fakeRootViewController.navigationItem setBackBarButtonItem:backButton]; // Set back button
                  // The parent navigation controller is the one containing the view controllers in portrait mode.
                  fakeRootViewController.parentNavigationController = parentNavigationController;
                  
                  UINavigationController* subNavigationController = // Initialize this the same way you have initialized your parent navigation controller.
                  
                  UIViewController* landscapeViewController = // Initialize the landscape view controller
                  
                  [subNavigationController setViewControllers:
                     [NSArray arrayWithObjects:fakeRootViewController, 
                                                                 landscapeViewController, nil] animated:NO];
                  
                  [_navigationController presentModalViewController:subNavigationController animated:YES];
                  

                  记住,landscapeViewController 也应该有这个实现:

                  Remember that the landscapeViewController should also have this implementation:

                  (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
                     return (interfaceOrientation == UIInterfaceOrientationIsLandscape(interfaceOrientation));
                  } 
                  

                  这篇关于UINavigationController 中仅支持一个视图的横向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 iOS7 中删除后退箭头 下一篇:对 &lt;UINavigationController: 0xa98e050&gt; 的开始/结束外观

                  相关文章

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

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

                      <legend id='REpwY'><style id='REpwY'><dir id='REpwY'><q id='REpwY'></q></dir></style></legend>