自动旋转在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
{
}
检查项目设置允许方向 - 必须选择所有支持,在这里http://stackoverflow.com/questions/15835084检查我的答案/ restrictting-autorotation-on-certain-views/15835584#15835584 – Stas 2013-04-08 07:14:44
是的,我选择了所有的方向。但不起作用 – Ram 2013-04-08 07:16:02
您是否在实际应该旋转的控制器中实现了这些方法? – Stas 2013-04-08 07:20:02