user1837396
user1837396

Reputation: 1

iOS 5.0 Modal View Not Rotating(Story Boards)

I use story boards. In every view controler I want to rotate I included this method like this:

- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)toInterfaceOrientation {
    return YES;
}

in iOS 6 it rotates just fine to the proper views I have for landscape and portrait in my story boards.

in iOS 5 the parent view contoller rotates but the modals don't rotate while they are on the screen, they only rotate before they are on the screen but never during. So when a user changes orientation it remains the same. A parent will change while on screen but the modal will take on the orientation the parent had but will not change while on screen. How do I get my modal views to work like iOS 6 where they will rotate when on the screen. The modal view were created via the storyboard.

Edit*

When I do a popover to a modal, the modal doesn't rotate. How can I fix this?

Upvotes: 0

Views: 471

Answers (1)

Ryan Poolos
Ryan Poolos

Reputation: 18551

Rotation is handled differently in iOS5 and iOS6. I use the below code to support both versions.

// iOS5
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}

// iOS6
- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;
}

- (BOOL)shouldAutorotate
{
    return YES;
}

shouldAutorotateToInterfaceOrientation: is deprecated in iOS6. You can read here: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/DeprecationAppendix/AppendixADeprecatedAPI.html#//apple_ref/occ/instm/UIViewController/shouldAutorotateToInterfaceOrientation:

Upvotes: 1

Related Questions