2013-04-08 105 views
0

自动旋转在ios6.1中不起作用。但下面的代码正在其他应用程序中工作。自动旋转不起作用ios6.1

代码:

@implementation UINavigationController (RotationIn_IOS6) 

-(BOOL)shouldAutorotate 
{ 
    return [[self.viewControllers lastObject] shouldAutorotate]; 
} 

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

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

@end 


- (BOOL)shouldAutorotate 
{ 
    //returns true if want to allow orientation change 
    return TRUE; 


} 
- (NSUInteger)supportedInterfaceOrientations 
{ 
    //decide number of origination tob supported by Viewcontroller. 
    return UIInterfaceOrientationMaskAll; 


} 

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation 
{ 
    //from here you Should try to Preferred orientation for ViewController 

    return UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight | UIInterfaceOrientationPortrait; 
} 

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation duration:(NSTimeInterval)duration 
{ 

} 
+0

检查项目设置允许方向 - 必须选择所有支持,在这里http://stackoverflow.com/questions/15835084检查我的答案/ restrictting-autorotation-on-certain-views/15835584#15835584 – Stas 2013-04-08 07:14:44

+0

是的,我选择了所有的方向。但不起作用 – Ram 2013-04-08 07:16:02

+0

您是否在实际应该旋转的控制器中实现了这些方法? – Stas 2013-04-08 07:20:02

回答

0

您是否尝试过修改的plist?

+0

是的。我已经做了.. – Ram 2013-04-08 07:47:54

1

ios6主要使用自动旋转的plist选项。尝试设置支持的方向字段。

0

请检查你的项目目标夏日就像下面

enter image description here

+0

我已经做了上述方法 – Ram 2013-04-10 07:25:03

+0

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { 返回YES; } – dhaya 2013-04-10 10:54:42

+0

- (BOOL)shouldAutorotate { return YES; } – dhaya 2013-04-10 10:55:46