Hot fix of Orientation Problem on iOS 6

By Posted 2012-09-23 14:28

Since iOS updated some orientation relatived methods, cocos2d-x games with v2.0.2 and before can’t be rendered to correct orientation.

I fixed it in this commit
You can update your games simply with the codes below:

  1. yougame/ios/ Change this line

    // Set RootViewController to window
    [window addSubview: viewController.view];


// Set RootViewController to window
if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0)
    // warning: addSubView doesn't work on iOS6
    [window addSubview: viewController.view];
    // use this mehod on ios6
    [window setRootViewController:viewController];
  1. In yourgame/ios/, we used this method to deal with auto rotation before ios6

    // Override to allow orientations other than the default portrait orientation.

    • (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationIsLandscape( interfaceOrientation ); }

But this method is deprecated since iOS 6. Instead, we need to add 2 methods in

// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead of shouldAutorotateToInterfaceOrientation
- (NSUInteger) supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskLandscape;

- (BOOL) shouldAutorotate {
    return YES;


Sign up for our newsletter to keep up with the latest developments, releases and updates for Cocos2d-x.