2012-10-03 63 views
0

我的应用程序的大部分不支持旋转。在支持的方向上,我只选择了portait。在该应用程序使用UIViewController子类我有这样的:ViewController不在iOS6上旋转

-(BOOL)shouldAutorotate { 
    return NO; 
} 

-(NSUInteger)supportedInterfaceOrientations { 
    NSLog(@"supported?"); 
    return UIInterfaceOrientationMaskPortrait; 
} 

-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { 

    NSLog(@"preferred"); 
    return UIInterfaceOrientationPortrait; 
} 

在UIViewController子类是不支持的方向,我有这样的:

-(BOOL)shouldAutorotate { 
    return YES; 
} 

-(NSUInteger)supportedInterfaceOrientations { 
    NSLog(@"supported?"); 
    return UIInterfaceOrientationMaskAll; 
} 

-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { 

    NSLog(@"preferred"); 
    return UIInterfaceOrientationPortrait; 
} 

我的应用程序不会对任何视图旋转。然而,包括这个。如何使它在这里旋转,因为我想要它?

+0

难道你在你的Info.plist中添加所有的方向到你支持的方向? – DrummerB

+0

不,我只将portait选为受支持的方向。如果我启用横向它只是旋转到每个视图控制器上的横向。 – Andrew

+1

你有导航控制器吗? – rooster117

回答

1

如果您使用的是导航控制器,确保你做这在App代表:

self.window.rootViewController = self.navigationController;

有关其他参考资料,检查所以这个问题:

Rotation behaving differently on iOS6

+0

这应该可以解决您的问题。有一天,我花了几个小时试图弄清楚这一点,很高兴最终我能够在我的应用程序代理上通过这一行解决它。 – atbebtg