升级到cocos2d 2.1版本后
对于横竖屏幕的问题解决比较容易
@implementation MyNavigationController
// 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;
// iPad only
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);
// iPad only
// iPhone only
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
在这2个方法中根据需要添加横竖屏,例外注意在info.plist中加入需要的屏幕类型(默认只加入了横屏幕)
本文介绍了如何在Cocos2d2.1版本中设置横竖屏显示,通过重写UIViewController的方法来控制不同设备的屏幕方向,并在Info.plist文件中配置支持的屏幕类型。

被折叠的 条评论
为什么被折叠?



