Search code examples
iphonecocoa-touchios5ios6

Device Rotation Not Working in IOS 6 Works Well in IOS 5 am I doing anything wrong?


-(BOOL)shouldAutorotate
{


    if (appDelegate.isOrientationSupport)
    {
        return YES;
    }
    else
    {
        return NO;
    }

}

-(NSInteger)supportedInterfaceOrientations{
    NSInteger mask = 0;
    if ([self shouldAutorotateToInterfaceOrientation: UIInterfaceOrientationLandscapeRight])
        mask |= UIInterfaceOrientationMaskLandscapeRight;
    if ([self shouldAutorotateToInterfaceOrientation: UIInterfaceOrientationLandscapeLeft])
        mask |= UIInterfaceOrientationMaskLandscapeLeft;
    if ([self shouldAutorotateToInterfaceOrientation: UIInterfaceOrientationPortrait])
        mask |= UIInterfaceOrientationMaskPortrait;
    if ([self shouldAutorotateToInterfaceOrientation: UIInterfaceOrientationPortraitUpsideDown])
        mask |= UIInterfaceOrientationMaskPortraitUpsideDown;
    return mask;
}

Where I am doing wrong?


Solution

  • in the AppDelegate:

    -(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window  // iOS 6
    {
    
    return UIInterfaceOrientationMaskAll;
    }
    

    in your ViewController:

    -(BOOL)shouldAutorotate {
    return YES;
    }
    
    -(NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
    }