Inferis/ViewDeck — Issue #28: shouldAutorotateToInterfaceOrientation doesn't honor modalViewController?
Author: schemers
Created: 2012-02-02 19:41:08+00:00
State: open

If you bring up the camera in ViewDeckExample and rotate, the camera view gets all messed up.

I think this is because IIViewDeckController shouldAutoroateToInterfaceOrientation doesn't honor whether or not a modal view controller on the center controller wants to allow rotation.

This patch fixes it, and stops the camera (UIImagePickerController) from rotating around and getting all confused.

Also fixes same issue I ran into in my app.

However, there is definitely a different behavior when running under IIViewDeckController and a standard controller for my app and modal view controllers (even with this fix):

A. with IIViewDeckController and this patch:

1. start out in portrait, and bring up a modal view that doesn't allow rotation
2. rotate to landcape, modal view doesn't rotate as expected
3. close modal view, original is still in portrait (need to rotate back to portrait

B. same app without IIViewDeckController

1. start out in portrait, and bring up a modal view that doesn't allow rotation
2. rotate to landcape, modal view doesn't rotate as expected
3. close modal view, original is in landscape

minor issue of course, but does make me wonder if there is a better fix.

Also wondering what happens when there is another modal view controller on top of the model view controller, etc. i.e., should we find the topmost modalViewController and ask it if we are allowed to rotate).

if (self.centerController) {
- // let the center controller handle the rotation behavior
- BOOL should = [self.centerController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
+ BOOL should;
+ if (self.centerController.modalViewController) {
+ // let the center controller modalViewController handle the rotation behavior
+ should = [self.centerController.modalViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
+ } else {
+ // let the center controller handle the rotation behavior
+ should = [self.centerController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
+ }
return should;
}