Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'
Xcode 4.6.1
cocos2d-iphone-2.1-rc1
Landscape Left, Right がデフォルトのcocos2dアプリなんて作らん!と、Portrait設定にしてビルド実行するとエラーが出てしまう場合があります。
それもこれも、iOS6からの画面の向きを監視するメソッドが変更されているせいで、シミュレータのバージョン6以上を使ってるとなう。
cocos2dプロジェクトを新規作成してAppDelegate.mを見れば一目瞭然の説明が記述されています。
これはiOS6だけ有効で、4/5では無効だからね
supportedInterfaceOrientations
これはiOS4/5だけ有効で、6では無効だからね
shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
-(NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
上記のようにOrientationsで指定した縦画面をリターンするように修正するか、これまたiOS6からのメソッドshouldAutorotateでNOを返せばsupportedInterfaceOrientationsは呼ばれないので、向きが固定のアプリケーションならこれでいいんじゃないですかね?
// iOS 6+ only
- (BOOL)shouldAutorotate
{
return NO;
}Universalにデザイン・コーディングするのはもちろん理想だけど、俺は縦画面がいいw