Posts Tagged ‘iOS6’

Orientation always in Portrait iOS6

Posted in code on October 1st, 2012 by admin – Be the first to comment

Right had to do a bit of research for this one, here is the fix I found that works from Natalie London

In your APP DELEGATE.m

NSString *reqSysVer = @"6.0";
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];

if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending){
    [window setRootViewController:viewController]; // This is for IOS6.....
}else{
    [window addSubview: viewController.view]; //This is for < IOS6....... (the old way)
}

In your ROOTVIEWCONTROLLER.m //will only be compiled for IOS6

FOR LANDSCAPE USE THIS

- (NSUInteger) supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
    return UIInterfaceOrientationLandscapeRight;
}

- (BOOL) shouldAutorotate {
    return YES;
}

FOR PORTRAIT USE THIS

- (NSUInteger) supportedInterfaceOrientations {
    returnĀ  UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
    return UIInterfaceOrientationPortrait;
}

- (BOOL) shouldAutorotate {
    return YES;
}

The page I got this from is

https://devforums.apple.com/message/734618#734618