Modal view controller does not rotate correctly in iOS 5.1, not 5.0

I have a main view controller that is in terrain (the whole application is left / right).

This main view is a modal view using:

ModalViewController *modalVC = [[ModalViewController alloc] init];
[modalVC setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[self presentModalViewController:modalVC animated:YES];


In iOS 5.0 * this works exactly as I would expect, with the main view in the landscape and the modal view appearing in the landscape.

In iOS 5.1, the main view is instantly rotated 90º to the left, and the modal view is then rotated 90º and cropped. When the modal view is rejected, the main view returns and is normal in landscape view.

I have tried all kinds of toAutorotateToInterfaceOrientation mutations and have no effect. I left it like this:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight) || (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);


I just can't figure it out, never had a problem until I just pasted iOS 5.1 on my iPhone and ran the app the first time on it.

Thanks in advance!

* This is confirmed with iPhone simulators 5.0 and 5.1


source to share

1 answer

Make sure you show the modal view controller (no animation) and before that:

[window makeKeyAndVisible]


So call

[uiviewcontroller presentViewController:modalViewController animated:NO completion:nil];
[window makeKeyAndVisible];




All Articles