0

我正在使用此类别来支持 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

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

4

1 回答 1

1

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

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

于 2013-05-10T11:40:19.047 回答