Cocos2dでPortrait固定にする
環境
Tool | Version |
---|---|
XCode | 4.6.1 |
Cocos2d | v2.1-rc1 |
編集箇所
テンプレートで作成したプロジェクトファイルの場合です。コメントの通り、iOS4/5とiOS6では呼び出されるメソッドが違うので2つ書きなおさないといけません。
// AppDelegate.m // The available orientations should be defined in the Info.plist file. // And in iOS 6+ only, you can override it in the Root View controller in the "supportedInterfaceOrientations" method. // Only valid for iOS 6+. NOT VALID for iOS 4 / 5. -(NSUInteger)supportedInterfaceOrientations { // iPhone only if( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone ) // return UIInterfaceOrientationMaskLandscape; return UIInterfaceOrientationMaskPortrait // iPad only // return UIInterfaceOrientationMaskLandscape; return UIInterfaceOrientationMaskPortrait; } // Supported orientations. Customize it for your own needs // Only valid on iOS 4 / 5. NOT VALID for iOS 6. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // iPhone only if( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone ) // return UIInterfaceOrientationIsLandscape(interfaceOrientation); return UIInterfaceOrientationIsPortrait(interfaceOrientation); // iPad only // iPhone only // return UIInterfaceOrientationIsLandscape(interfaceOrientation); return UIInterfaceOrientationIsPortrait(interfaceOrientation); }