Orientation always in Portrait iOS6

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

Change Cocos2D template to portrait

The template that comes with Cocos2D 0.99.5 is set in landscape mode. Sometimes you want portrait though, so I did the following and it seems to work, and reorient without fail.

In GameConfig.m


// REPLACE THIS LINE #define GAME_AUTOROTATION kGameAutorotationNone
// WITH THE FOLLOWING
#define GAME_AUTOROTATION kGameAutorotationUIViewController

In RootviewController.m in the section of

#elif GAME_AUTOROTATION == kGameAutorotationUIViewController

// EAGLView will be rotated by the UIViewController
//
// Sample: Autorotate only in landscpe mode
//
// return YES for the supported orientations

// REPLACE THIS LINE return ( UIInterfaceOrientationIsLandscape( interfaceOrientation ) );
// WITH THE FOLLOWING
return ( UIInterfaceOrientationIsPortrait( interfaceOrientation ) );

In your appdelegate.m class file


[director setAnimationInterval:1.0/60];
[director setDisplayFPS:YES];
// ADD THE FOLLOWING LINE HERE
[director setDeviceOrientation:kCCDeviceOrientationPortrait];