Reputation: 13
I have an app that just needs one screen to autorotate, the first and last screens should be portrait. I can get the last screen to stop rotating using:
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
But this does not work on the first screen, I am using a storyboard with a UINavigationController
(I'm thinking that may have something to do with it?)
Any help would be gratefully received. Thanks
Upvotes: 1
Views: 37
Reputation: 24041
you may need to subset the UINavigationController
and you should use it instead of the standard UINavigationController
.
I have done this in my projects, so this cares of the individual UIViewController
classes' custom orientations:
#import <UIKit/UIKit.h>
@interface UIOrientationController : UINavigationController { }
@end
@implementation UIOrientationController
- (BOOL)shouldAutorotate {
return [self.topViewController shouldAutorotate];
}
- (NSUInteger)supportedInterfaceOrientations {
return [self.topViewController supportedInterfaceOrientations];
}
@end
NOTE: you can extended this class with overriding more methods, if it becomes a requirement in your final code.
Upvotes: 1