0
votes

I've created a container view controller in which I can embed a child view controller (using the new iOS 5 API). When a child view controller is embedded that only supports the portrait orientation, and the device is currently in landscape orientation, I want to force a rotation to portrait.

I found the [UIViewController attemptRotationToDeviceOrientation] method which almost does this, but not quite. It actually works the opposite way, so that if the child view controller is embedded, and the device is in portrait orientation, I can rotate to landscape (but the view controller will remain portrait), then dismiss the embedded view controller, and it will automatically rotate to landscape.

Is there any way to force the container view controller to rotate when embedding a child view controller that doesn't support the current orientation?

1
I think there is a way. If I understand exactly, I think I worked with something similar in the past. Did you try something like - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Overriden to allow any orientation. if(embeded child)return NO; return YES; }BBog
Yes, I am currently doing that. The problem is, that callback doesn't get called when the child view controller is embedded. Only on rotation, or when calling [UIViewController attemptRotationToDeviceOrientation] while in an orientation that does not match the device orientation.Hilton Campbell

1 Answers

0
votes

I'll bet money this isn't a satisfying answer, BUT...I think you have to abandon rotation and move to an affine transform (of the subview) of 90 degrees. Rotation is a physical act of the user, and try as we might we can't actually rotate the device. However, a transform is within your power. You can always set it back to the identity once the user complies and rotates the device to the proper orientation.

Have fun & good luck,

Damien