Autorotate works for iOS 6 but gives weird behavior in iOS 5

Posted by Jeanne on Stack Overflow See other posts from Stack Overflow or by Jeanne
Published on 2012-11-01T14:47:35Z Indexed on 2012/11/01 17:01 UTC
Read the original article Hit count: 883

Filed under:
|
|
|

I seem to be having the opposite problem from this post:

Autorotate in iOS 6 has strange behaviour

When I submitted my paid app to Apple, XCode made me update to iOS 6 on my test devices. I used the GUI in XCode to set my app to display only in portrait mode on the iPhone and only in landscape mode on the iPad. This works great on my iOS 6 iPhone and iPad. In iOS 5, however, the iPad is allowing the app to rotate to portrait, displaying my buttons in a letterbox-like black area that shouldn't be there, and crashing repeatedly.

I am using a Navigation Controller and storyboards.

I know shouldAutorotateToInterfaceOrientation is deprecated in iOS 6, but figuring it should still be called in iOS 5, I tried this:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    {
        if ((UIDeviceOrientationIsLandscape(UIDeviceOrientationLandscapeLeft))||(UIDeviceOrientationIsLandscape(UIDeviceOrientationLandscapeRight))) {
            return YES;
        }
        else return NO;
    }
    else
    {
        if ((UIDeviceOrientationIsLandscape(UIDeviceOrientationPortrait))||(UIDeviceOrientationIsLandscape(UIDeviceOrientationPortraitUpsideDown))) {
            return YES;
        }
        else return NO; }
    // Return YES for supported orientations
}

The above code seems to have done nothing. I am putting it in each of my view controllers; it seems I should really be putting it in my navigation controller, but because I set that up graphically, I'm not sure how to do that. Do I have to subclass my navigation controller and do everything in code? There must be a way to use the storyboard settings for this!

(Note: I am not using AutoLayout and apparently can't because of some older components I am including my software that just plain don't like it.)

What might be causing this? I'd like to fix it before too many people buy the app and complain! Thanks in advance...

© Stack Overflow or respective owner

Related posts about ios

Related posts about ios5