shouldAutorotateToInterfaceOrientation the iOS6 way


#1

So this code is, according to the documentation, deprecated

// deprecated in iOS6
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)io
{
    if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
    {
        return YES;
    }
    else
    {
        return (io == UIInterfaceOrientationPortrait);
    }
}

The new equivalent code is:

// the iOS 6 way!
-(NSUInteger)supportedInterfaceOrientations
{
    if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
    {
        return UIInterfaceOrientationMaskAll;
    }
    else
    {
        return UIInterfaceOrientationMaskLandscape | UIInterfaceOrientationMaskPortrait;
    }
    
}

I noticed that for this to work, you need to first enable all orientations in the project’s Target Summary. (Supported Interface Orientations).