shouldAutorotate crash

hi, on iOS6(device and simulator) I write:

  • (BOOL) shouldAutorotate {
    return YES;
    }

the game crash with:

2013-01-08 12:18:38.084 Boom[97446:15203] *** Terminating app due to uncaught exception ‘UIApplicationInvalidInterfaceOrientation’, reason: ‘Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES’
*** First throw call stack:

why?
on iOS5.1 (simulator) I don’t have this problem.
the game is in portrait.

Thanks!

Stefano

ok, the game not crashed, if supportedInterfaceOrientations returns UIInterfaceOrientationMaskPortrait. But I don’t have the autorotation.
any idea?

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

// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead

  • (NSUInteger) supportedInterfaceOrientations{
    #ifdef __IPHONE_6_0
    return UIInterfaceOrientationMaskPortrait;
    #endif
    }

  • (BOOL) shouldAutorotate {
    return YES;
    }

Stefano Campodall’Orto wrote:

hi, on iOS6(device and simulator) I write:
>

  • (BOOL) shouldAutorotate {
    return YES;
    }
    >
    the game crash with:
    >
    2013-01-08 12:18:38.084 Boom[97446:15203] * Terminating app due to uncaught exception ‘UIApplicationInvalidInterfaceOrientation’, reason: ‘Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES’
    >
    * First throw call stack:
    >
    why?
    on iOS5.1 (simulator) I don’t have this problem.
    the game is in portrait.
    >
    Thanks!
    >
    >
    Stefano

Stefano Campodall’Orto wrote:

ok, the game not crashed, if supportedInterfaceOrientations returns UIInterfaceOrientationMaskPortrait. But I don’t have the autorotation.
any idea?
>

  • (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return UIInterfaceOrientationIsPortrait( interfaceOrientation );
    }
    >
    // For ios6, use supportedInterfaceOrientations & shouldAutorotate instead
  • (NSUInteger) supportedInterfaceOrientations{
    #ifdef __IPHONE_6_0
    return UIInterfaceOrientationMaskPortrait;
    #endif
    }
    >
  • (BOOL) shouldAutorotate {
    return YES;
    }
    >
    Stefano Campodall’Orto wrote:
    > hi, on iOS6(device and simulator) I write:
    >
    > - (BOOL) shouldAutorotate {
    > return YES;
    > }
    >
    > the game crash with:
    >
    > 2013-01-08 12:18:38.084 Boom[97446:15203] * Terminating app due to uncaught exception ‘UIApplicationInvalidInterfaceOrientation’, reason: ‘Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES’
    >
    * First throw call stack:
    >
    > why?
    > on iOS5.1 (simulator) I don’t have this problem.
    > the game is in portrait.
    >
    > Thanks!
    >
    >
    > Stefano

I am having the same issue since upgrading to 2.1.2. My supported orientations include portrait and the game is in portrait.

Hello! I have the same issue with 2.2. Is there any solution?

I was having a similar issue in the c++ versions of cocos2d-x 2.2.3 and 3.1.1 running on iPhone 3gs with iOS 6.0 (10A403).

My issue was with a landscape app launching in landscape and then showing the crash exception:

*** Terminating app due to uncaught exception ‘UIApplicationInvalidInterfaceOrientation’, reason: ‘Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES’

To fix the crash, I added the following code to the AppController.mm

-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        return UIInterfaceOrientationMaskAll;
    }
    else {
        return UIInterfaceOrientationMaskAllButUpsideDown;
    }
}

This only partially fixed the issue, since the game would now run, but could also rotate to portrait too, which is not what I wanted for a landscape only game. To fix that issue I updated the code in RootViewController.mm to this:

// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead
- (NSUInteger) supportedInterfaceOrientations{
#ifdef __IPHONE_6_0
    return UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskLandscapeLeft;
#endif
}

Also, make sure that your info.plist ‘Supported interface orientations’ matches what you specify in code.

I have tested this fix for landscape games on iphone 3gs running 6.0, iphone 3gs running 5.1.1, ipad 1 running 5.1.1, ipad 3 running 7.1.1 and iphone 5s running 7.1.1, iphone 4s running 5.1.1, and an iphone 4 running 7.0 and all work as expected.