我使用此类别支持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];
}
我的应用程序设置就像这样
-(BOOL)shouldAutorotate
在主屏幕中实现 谁知道如何解决这个问题?
答案 0 :(得分:1)
根据this question的答案,使用Category来覆盖Cocoa类中的方法是一个坏主意。 '关于在运行时使用哪种方法实现,行为未定义。
我使用UINavigationController的子类来实现你想要做的事情并且没有任何问题所以我建议你尝试一下。