Cocos2d-iOS中的设备方向
发布时间:2020-12-14 17:24:44 所属栏目:百科 来源:网络整理
导读:Xcode:7.1,运行于:iPhone 6s Plus 我的AppDelegate.mm有以下代码: - (void) applicationDidFinishLaunching:(UIApplication*)application---------some code#if GAME_AUTOROTATION == kGameAutorotationUIViewController NSLog(@"if"); [director setDevi
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; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |