Cocos2d-iOS中的设备方向

Cocos2d-iOS中的设备方向,第1张

概述Xcode:7.1,运行于:iPhone 6s Plus 我的AppDelegate.mm有以下代码: - (void) applicationDidFinishLaunching:(UIApplication*)application---------some code#if GAME_AUTOROTATION == kGameAutorotationUIViewController 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;}
总结

以上是内存溢出为你收集整理的Cocos2d-iOS中的设备方向全部内容,希望文章能够帮你解决Cocos2d-iOS中的设备方向所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1005842.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存