【问题标题】:How to rotate a single View Controller in IOS6如何在 IOS6 中旋转单个视图控制器
【发布时间】:2012-11-29 21:56:51
【问题描述】:

如何在 ios6 中在 iPad 中旋转单个 ViewController。我在

中使用了委托

appdelegate.m

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

它使所有viewcontroller 成为纵向,我想要一个viewcontroller 仅在横向模式之间。

在graphViewController.m中

- (BOOL)shouldAutorotate
{
    return NO;
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}

但我无法得到正确的结果,请尽快回复。谢谢。

【问题讨论】:

  • 我认为您应该在 appDelegate 中同时支持方向并为每个 ViewController 设置supportedInterfaceOrientations。
  • 你在导航控制器中吗?

标签: iphone ios6


【解决方案1】:

查看此链接iOS6 Release Notes

在 UIKit 下 -> iOS 6 中的自动旋转正在发生变化

“更多的责任正在转移到应用程序和应用程序委托。现在,iOS 容器(例如 UINavigationController) 不要咨询他们的孩子来决定他们是否应该 自动旋转。”

shouldAutorotate 永远不会在另一个控制器(例如 UINavigationController)内的任何 UIViewController 中调用(在 iOS6 中)。

您应该使用 UINavigationController 的 shouldAutorotate 方法(如果您使用一个)来确定显示哪个子项并强制给定方向

【讨论】:

  • 我写了 UINaviogationController 旋转的代码,viewcontroller 是横向旋转的,但 StatusBar 是纵向的。
  • @ManojChandola 也许,在您的问题下方,进行 en EDIT 并在编辑中提供您现在拥有的旋转代码,以便我们查看它。
【解决方案2】:

在要旋转的 viewController 中使用此方法,而不是在 app delegate.m 中

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

因为在下面的方法中您正在旋转窗口,所以这就是为什么它会改变整个应用程序。

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

【讨论】:

  • shouldAutorotateToInterfaceOrientation 在 iOS6 中已被弃用,问题是特定于 iOS6 的。
  • shouldAutorotateToInterfaceOrientation 委托在 iOS6 中已弃用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-10-13
  • 1970-01-01
  • 2017-11-05
  • 2013-02-14
相关资源
最近更新 更多