xcode 4.5中Cocos2d 屏幕方向问题
来源:互联网 发布:好玩的网络格斗游戏 编辑:程序博客网 时间:2024/05/20 07:34
由于设备升级到了ios6的系统,所以为了调试,xcode也升级到了4.5,但是,当我运行以前的cocos2d工程的时候,发现本来是横屏的游戏,变成了竖屏,而且新建的cocos2d工程也是有这个问题。
所以经过一系列的调试,修改,查阅文档。发现最新的帮助文档里面写到:
In iOS 6, your app supports the interface orientations defined in your app’s Info.plist
file. A view controller can override the supportedInterfaceOrientations
method to limit the list of supported orientations. Generally, the system calls this method only on the root view controller of the window or a view controller presented to fill the entire screen。
上面红色着重标记了一下关键字。大概意思也就是在ios6中,一般是在Info.plist里面来设置这个app需要的方向,或者重写
supportedInterfaceOrientations这个方法,而且为了系统能够调用这些东西,你需要设置这个view controller是这个window的root view controller或者弹出充满整个屏幕这个一个view controller。而在coocos2d模板创建的工程当中使用的是:
[window addSubview: viewController.view];
所以我们怎么设置Info.plist都是没有用的。而且view controller官方文档直接写明了:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation NS_DEPRECATED_IOS(2_0, 6_0);
这个shouldAutorotateToInterfaceOrientation在ios6中被弃用了,所以在RootViewController.m中这个函数怎么都不会被调用了。
不过在这个类里面还有一个
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
不过经过测试也发现没有被调用。
这个时候,你要是把addsubview那句改成:
[window setRootViewController:viewController];
这个时候,你就可以发现你的cocos2d工程恢复了正常了,而且willRotateToInterfaceOrientation也被调用了。
- xcode 4.5中Cocos2d 屏幕方向问题
- Cocos2d-x中移植到Android真机上屏幕方向设置
- cocos2d 设置屏幕默认方向
- cocos2d 设置屏幕默认方向
- ios编程:xcode如何更改屏幕方向
- ios开发过程中屏幕方向判断的问题
- ios开发过程中屏幕方向判断的问题
- cocos2d-x 修改安卓屏幕方向
- cocos2d-iphone 2.x 屏幕方向对ios6的支持问题
- iOS开发中屏幕旋转至一个方向后再手动设置屏幕旋转至该方向无效问题
- Android中屏幕的方向
- XCODE中新建工程出现无法获取屏幕尺寸问题
- Cocos2d-x 3.0 Android修改APK名、更改图标、修改屏幕方向、修改版本号,一些需要注意的问题
- Cocos2d-x 3.0 Android修改APK名、更改图标、修改屏幕方向、修改版本号,一些需要注意的问题
- cocos2d-x 获取屏幕当前方向和系统语言
- cocos2d-x 获取屏幕当前方向和系统语言
- Cocos2D-iphone 开发之 设置屏幕方向(Interface Orientation)
- quick-cocos2d-x 如何设置游戏的屏幕方向
- apk的安装:INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES
- 湖南粮食局长体验禁食1天后5分钟喝完大碗汤-湖南-粮食局-禁食
- linux下安装git
- 有关onActivityResult提前调用的问题
- java io流操作
- xcode 4.5中Cocos2d 屏幕方向问题
- linux下错误的捕获:errno和strerror的使用
- 移植Discuz!X2.5到SAE平台手记 1
- poj2663 Tri Tiling dp递推
- 很牛的一个多媒体技术的网络资料
- 设备驱动程序INF文件——INF文件的节
- Android iphone对话
- 怎么通过http向服务器发送数据并接受到返回的数据
- 施一公:优秀博士如何养成(全文) 清华大学演讲