奇怪的iOS 6自动旋转Bug

时间:2013-05-10 10:49:07

标签: iphone ios6.1 auto-rotation

我使用此类别支持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. 验证用户并显示主屏幕旋转仅适用于模拟器而非设备
  3. -(BOOL)shouldAutorotate

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

1 个答案:

答案 0 :(得分:1)

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

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