The root window controller of my application window is a subclass of UINavigationController. I added this code to the class:
- (BOOL)shouldAutorotate { return [self.topViewController shouldAutorotate]; } - (NSUInteger)supportedInterfaceOrientations { return [self.topViewController supportedInterfaceOrientations]; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return [self.topViewController preferredInterfaceOrientationForPresentation]; }
In my root UIViewController, I added this code:
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationPortrait; } - (BOOL)shouldAutorotate { return NO; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationPortrait; }
When the device is turned to terrain on this view controller, I present the modal view controller. When the device is turned back to the portrait, I have to reject the modal view, but when I do this, I get the following error:
'preferredInterfaceOrientationForPresentation must return a supported interface orientation!'
Why am I getting this error?
I tried to return YES from mustAutorotate to the root UIViewController, and now I get an error. "Supported orientations do not have a common orientation with the application, and shouldAutorotate returns YES." This doesn't make sense to me, because UIInterfaceOrientationPortrait is one of the supported orientation apps.
source share