I seem to be having difficulties with my iOS Application.
It's deployment target is iOS5.0, however I am using the iOS 6.0 SDK.
In my View Controller I have:
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationMaskPortrait;
}
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return (toInterfaceOrientation == UIInterfaceOrientationPortrait);
}
This works fine when running in the iOS5 simulator. The view will not rotate to LandScape or upside down.
However, in the IOS6 Simulator (and on a Device), it will continue to rotate.
I have used NSLog
to check that -supportedInterfaceOrientations
does get called and it does, twice, however it still rotates to LandScape (right or left)
What am I doing wrong?
I've also extended the UINavigationController
(My Root View Controller) to include this:
@implementation UINavigationController (Rotation_IOS6)
-(BOOL)shouldAutorotate
{
return [[self.viewControllers lastObject] shouldAutorotate];
}
-(NSUInteger)supportedInterfaceOrientations
{
return [[self.viewControllers lastObject] supportedInterfaceOrientations];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
}
@end
But with still no success.
Edit
As per matt's answer. I also needed to extend the UITabBarController with a similar implementation to my UINavigationController and that worked.