导航

Cocos2d-2.0横竖屏

Posted on 2013-01-14 22:45  ADaii  阅读(465)  评论(0编辑  收藏  举报

Cocos2d-2.0横竖屏设置

<AppDelegate.m>iOS 6+设置使用

 1 // Only valid for iOS 6+. NOT VALID for iOS 4 / 5.
 2 -(NSUInteger)supportedInterfaceOrientations {
 3     
 4     // iPhone only
 5     if( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone )
 6         return UIInterfaceOrientationMaskPortrait;  //竖屏设置
 7         //return UIInterfaceOrientationMaskLandscape;    //横屏设置
 8     
 9     // iPad only
10     return UIInterfaceOrientationMaskPortrait;  //竖屏设置
11     //return UIInterfaceOrientationMaskLandscape;    //横屏设置
12 }

<AppDelegate.m>iOS 4/5设置使用

 1 // Only valid on iOS 4 / 5. NOT VALID for iOS 6.
 2 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
 3 {
 4     // iPhone only
 5     if( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone )
 6         return UIInterfaceOrientationIsPortrait(interfaceOrientation);  //竖屏设置
 7         //return UIInterfaceOrientationIsLandscape(interfaceOrientation);   //横屏设置
 8     
 9     // iPad only
10     // iPhone only
11     //return UIInterfaceOrientationIsLandscape(interfaceOrientation);   //横屏设置
12     return UIInterfaceOrientationIsPortrait(interfaceOrientation);  //竖屏设置
13 }