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 ) );
我的Xcode设置是:
虽然设备方向转向横向,但游戏仍然以纵向显示.游戏截图如下:
最佳答案 在RootViewController.m中添加supportedInterfaceOrientations函数
-(NSUInteger)supportedInterfaceOrientations {
// iPhone only
if( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone )
return UIInterfaceOrientationMaskLandscape;
// iPad only
return UIInterfaceOrientationMaskLandscape;
}