【Cocos2d-x】 关于IOS设置竖屏后,运行会报错的解决方法
来源:互联网 发布:vscode eslint 编辑:程序博客网 时间:2024/06/05 07:19
今天移植Cocos2d项目的时候,运行的时候老是出现异常:Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES' 。原因是:游戏需要竖屏显示,因为修改了RootViewController.mm里面的两个函数的返回值,分别是:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // return UIInterfaceOrientationIsLandscape( interfaceOrientation );// 横屏 return UIInterfaceOrientationIsPortrait(interfaceOrientation);// 竖屏}
- (NSUInteger) supportedInterfaceOrientations{#ifdef __IPHONE_6_0 // return UIInterfaceOrientationMaskAllButUpsideDown; return UIInterfaceOrientationMaskPortrait; // 竖屏#endif}
出现了问题。解决这个问题有几个方法:
方法1:将RootViewController.mm里面的shouldAutorotate()函数返回值改成NO,如:
- (BOOL) shouldAutorotate { return NO;}改了之后可以正常运行,但是会有个问题,如果你的游戏里面有加了Chartboost插屏广告,该广告是横屏显示的,这显然不是我想要的。
方法2:修改ios目录下的info.plist文件。点开info.plist文件,找到“Supported interface orientations”这个设置项,修改Item0的值为:Portrait (bottom home button)。能正常运行程序,且Chartboost插屏广告也是按照竖屏来显示,问题解决!
0 0
- 【Cocos2d-x】 关于IOS设置竖屏后,运行会报错的解决方法
- IOS Cocos2d-x 设置竖屏的方法
- ios cocos2d-x 设置 横屏 竖屏
- cocos2d-x 在simulator中运行闪退显示thread 1:breakpoint 1.1的解决方法
- 【Cocos2d-X开发学习笔记】解决Cocos2d-X新建项目运行报错的问题
- 【Cocos2d-X开发学习笔记】解决Cocos2d-X新建项目运行报错的问题
- Cocos2d-x 2.x设置竖屏方法 android ios
- 关于Tapestry5运行时报错的解决方法。
- Cocos2d-x 3.0 新建一个场景并设置为项目启动时自动运行的场景
- OpenCV使用detectMultiScale可能会报错_CrtIsValidHeapPointer的解决方法
- eclipse下不能编译.ftl文件,会报错的解决方法
- cocos2d-x 3.13编译慢的解决方法
- Cocos2d-x 怎样支持多点触摸(IOS上多点失灵的解决方法)
- 关于Cocos2d-x android的环境搭建、Demo运行的注意事项。
- xcode4运行cocos2d-x的tests工程
- 【cocos2d-x】让XCode运行时自动更新资源【IOS】
- 【cocos2d-x】让XCode运行时自动更新资源【IOS】
- 在Android线程中设置控件的值会报错
- 游戏开发中的数学和物理算法(6):圆和球的碰撞检测
- unity android环境
- 一种高效简单的缓存机制
- matlab c++ 画图【转载】
- 域名年龄-SEO搜索引擎优化
- 【Cocos2d-x】 关于IOS设置竖屏后,运行会报错的解决方法
- android碎片Fragment简介详解
- 图片处理类,用来生成缩略图
- 黑马程序员---学生管理系统 (转载)
- iOS-UITextField类
- Lua中的IO库
- (转)linux口令相关文件(/etc/passwd和/etc/shadow)
- 游戏开发中的数学和物理算法(7):角度 vs 弧度
- Bitmap二次采样