My application window's root view controller is a subclassed UINavigationController. I have 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 have added this code:
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
- (BOOL)shouldAutorotate
{
return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationPortrait;
}
When the device is rotated to landscape on this view controller, I present a modal view controller. When the device is rotated back to portrait, I am supposed to dismiss the modal view, but when I do I get the following error:
'preferredInterfaceOrientationForPresentation must return a supported interface orientation!'
Why am I getting this error?
I tried returning YES from shouldAutorotate in the root UIViewController, and now I get the error 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'. This makes no sense to my, because UIInterfaceOrientationPortrait is one of the applications supported orientations.