【问题标题】:Strange iOS6 AutoRotate Bug奇怪的 iOS6 自动旋转错误
【发布时间】:2013-05-10 10:49:07
【问题描述】:

我正在使用这个类别来支持 ios 6 中的自动旋转

@implementation UINavigationController (RotationIn_IOS6)

-(BOOL)shouldAutorotate
{
    NSLog(@"Last Object is %@",[[self.viewControllers lastObject] description]);
    return [[self.viewControllers lastObject] shouldAutorotate];
}

-(NSUInteger)supportedInterfaceOrientations
{
    return [[self.viewControllers lastObject] supportedInterfaceOrientations];
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return [[self.viewControllers lastObject]  preferredInterfaceOrientationForPresentation];
}

我的应用设置是这样的

  1. 显示带有导航控制器旋转的密码屏幕适用于两者(模拟器、设备)。
  2. 验证用户并显示主页屏幕旋转仅适用于模拟器而不适用于设备

-(BOOL)shouldAutorotate

在主屏幕中实现 有谁知道如何解决这个问题?

【问题讨论】:

  • 真正的问题是什么?
  • 您是否在“主屏幕”视图控制器中实现了-(NSUInteger)supportedInterfaceOrientations
  • 设备的 iOS 版本是什么?
  • @MikePollard 是 supportInterfaceOrientations 已实现
  • @MaxMacLeod 主屏幕不会在设备中旋转,但在模拟器中会旋转

标签: iphone ios6.1 autorotate


【解决方案1】:

根据this question 的答案,使用类别覆盖 Cocoa 类中的方法是一个坏主意。 '对于在运行时使用哪种方法实现,行为未定义'。

我使用 UINavigationController 的子类来实现您想要做的事情并且没有遇到任何问题,所以我建议您尝试一下。

【讨论】:

  • 可能是因为 iPhone 越狱了……反正会在非越狱设备上测试,然后在这里更新帖子
  • 为什么不避免在运行时出现“未定义行为”的可能性,而使用子类呢?
  • 是的,肯定会使用子类
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-12-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多