【问题标题】:UIViewController in UINavigationController does not rotate as expectedUINavigationController 中的 UIViewController 未按预期旋转
【发布时间】:2011-04-22 23:27:03
【问题描述】:

我有一个 UINavigationController,它的根 UIViewController 只支持纵向。当用户按下按钮时,第二个 UIViewController 被加载并推送到堆栈上,这个视图控制器,我们称之为 secondViewController,只支持横向。

通常会发生的情况是界面在转换到 secondViewController 期间旋转,但尽管 shouldAutorotateToInterfaceOrientation: 在 secondViewController 上被调用,但不会发生这种情况。一旦我在显示 secondViewController 时手动倾斜设备,它就会按预期旋转,当切换回第一个 UIViewController 时,它会按原样旋转回纵向。

为了测试第一个UIViewController允许的界面Orientations是否对进程有影响,我设置了一个return YES;但是,对于那里的所有接口,问题仍然存在。我还阅读了technical Q&A on the subject,但根据这个文档,一切都应该没问题,UINavigationController 是窗口的唯一子视图。

我完全以编程方式创建了 secondViewController(覆盖 loadView),并且之前在其他应用程序中使用过这个特殊情况。有人知道我可能做错了什么吗?

【问题讨论】:

    标签: iphone cocoa-touch uiviewcontroller uinavigationcontroller autorotate


    【解决方案1】:

    显然更改不会自动发生,以下给出了必要的“推送”:

    - (void) viewWillAppear:(BOOL)animated {
        [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-14
      • 1970-01-01
      • 2015-01-11
      • 1970-01-01
      • 1970-01-01
      • 2015-06-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多