0

Autorotation is not working in ios6.1. But following code is working in other app.

code:

@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
{

}
Ram
  • 1,687
  • 3
  • 18
  • 28
  • Check your project settings for allowed orientations - all supported must be selected , check my answer here http://stackoverflow.com/questions/15835084/restricting-autorotation-on-certain-views/15835584#15835584 – Stas Apr 08 '13 at 07:14
  • Yes I selected all orientation. But not working – Ram Apr 08 '13 at 07:16
  • Did you implement these method in the controllers that should actually rotate? – Stas Apr 08 '13 at 07:20
  • yes i implemented in viewcontroller – Ram Apr 08 '13 at 07:20
  • it seems that you made a typo somewhere, check your code carefully one more time. – Stas Apr 08 '13 at 07:21
  • Did you set your window's rootViewController ? Or add subview? – Mani Apr 08 '13 at 07:24
  • HomeVC *home_obj=[[HomeVC alloc]init]; UINavigationController *nav1=[[UINavigationController alloc]initWithRootViewController:home_obj]; [window addSubview:nav1.view]; //window.rootViewController=nav1; [self.window makeKeyAndVisible]; – Ram Apr 08 '13 at 07:31
  • Yes, I also experienced with same problem. I solved by setting `window.rootViewCotroller = nav1 ;` You can try this. I hope this will be work.. – Mani Apr 08 '13 at 07:34
  • when i use window.rootViewCotroller = nav1. My viewcontroller is transparent view display. Nothing shows inside view – Ram Apr 08 '13 at 07:43

3 Answers3

1

ios6 uses mainly the plist options for autorotation. Try to setup the supported orientations fields.

0

Have you tried to modify the plist?

BalestraPatrick
  • 9,944
  • 4
  • 30
  • 43
0

Please check your project targets summery is like below

enter image description here

dhaya
  • 1,522
  • 13
  • 21