天天看点

cocos2d 设置屏幕默认方向

在cocos2d创建的新工程运行结果屏幕都是横向,控制代码

这段代码控制的是屏幕视图默认横向显示;

还有一个需要区别的是硬件设备方向(灰黑色背景表示被选择,所支持方向)

当你旋转设备方向时候,发现当屏幕竖着的时候,视图里面内容并未调整,标签HelloWord并未横着放

如果想让运行时候默认竖屏,修改代码返回值(或者 return YES;也行)

设备支持方向前两个必选,后面两个看需要,需要的话也可以选上;

 UIInterfaceOrientationIsPortrait和UIInterfaceOrientationIsLandscape在UIApplication.h文件中宏定义

#define UIInterfaceOrientationIsPortrait(orientation)  ((orientation) == UIInterfaceOrientationPortrait || (orientation) == UIInterfaceOrientationPortraitUpsideDown)

#define UIInterfaceOrientationIsLandscape(orientation) ((orientation) == UIInterfaceOrientationLandscapeLeft || (orientation) == UIInterfaceOrientationLandscapeRight)

     本文转自新风作浪 51CTO博客,原文链接:http://blog.51cto.com/duxinfeng/1208775,如需转载请自行联系原作者

继续阅读