uaka
uaka

Reputation: 13

in iOS7 how do you stop the First viewcontroller autorotating?

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

Answers (1)

holex
holex

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:

.h

#import <UIKit/UIKit.h>

@interface UIOrientationController : UINavigationController { }
@end

.m

@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

Related Questions