Xcode:7.1,运行于:iPhone 6s Plus
我的 AppDelegate.mm 有以下代码:
- (void) applicationDidFinishLaunching:(UIApplication*)application
---------some code
#if GAME_AUTOROTATION == kGameAutorotationUIViewController
NSLog(@"if");
[director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];
#else
NSLog(@"else");
[director setDeviceOrientation:kCCDeviceOrientationPortrait];
#endif
---------somecode
我的 GameConfig.h 有:
#define GAME_AUTOROTATION kGameAutorotationUIViewController
我的 RootViewController.m 有:
if GAME_AUTOROTATION == kGameAutorotationUIViewController
return ( UIInterfaceOrientationIsLandscape( interfaceOrientation ) );
最佳答案
在RootViewController.m中添加supportedInterfaceOrientations函数
-(NSUInteger)supportedInterfaceOrientations {
// iPhone only
if( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone )
return UIInterfaceOrientationMaskLandscape;
// iPad only
return UIInterfaceOrientationMaskLandscape;
}
关于ios - Cocos2d-iOS 中的设备方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33922793/