Is there a documented way to set the iPhone orientation?

This is long after the fact, but just in case anybody comes along who isn’t using a navigation controller and/or doesn’t wish to use undocumented methods:

UIViewController *c = [[UIViewController alloc]init];
[self presentModalViewController:c animated:NO];
[self dismissModalViewControllerAnimated:NO];
[c release];

It is sufficient to present and dismiss a vanilla view controller.

Obviously you’ll still need to confirm or deny the orientation in your override of shouldAutorotateToInterfaceOrientation. But this will cause shouldAutorotate… to be called again by the system.

Leave a Comment