【问题标题】:Unwanted UIView Autorotating: Navigation Controller Push不需要的 UIView 自动旋转:导航控制器推送
【发布时间】:2011-09-27 21:25:55
【问题描述】:

我有一个导航控制器,它以纵向方式通过它。然后,在某个时刻,我推送到一个显示图表的视图,我只想以横向显示,甚至根本不以纵向显示(这搞砸了视图的外观)。

在这个视图中,GraphViewController,我有如下方法:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}

当视图第一次被推送时,它以纵向模式显示。如果我旋转手机,视图也会旋转成横向(而不是倒置纵向)。但我希望它永远不要处于纵向模式,即使它开始时也不行。我已经通过添加 NSLog 验证了此方法正在被调用。

我看到了 these posts 但无法让它工作。谢谢!!

【问题讨论】:

  • 你设法让它工作了吗?

标签: iphone objective-c uinavigationcontroller autorotate


【解决方案1】:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

【讨论】:

  • 呃,没有。我要说的是,这行不通。我的视图仍然以纵向模式打开。此外,您(实际上)给了我上面发布的相同代码。不过我确实尝试过,同样的事情发生了:当视图被推送时,它处于纵向模式。
猜你喜欢
  • 2015-08-30
  • 1970-01-01
  • 2015-08-21
  • 1970-01-01
  • 2013-07-19
  • 2015-08-11
  • 2014-01-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多