首页 > 移动平台 > 详细

cocos2dx如何设置ios和Android横屏竖屏的几种方法

时间:2014-09-02 20:03:25      阅读:285      评论:0      收藏:0      [点我收藏+]

IOS通用的

只需要在RootViewController.mm文件里面

1

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return UIInterfaceOrientationIsPortrait( interfaceOrientation );
}
 
// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead
- (NSUInteger) supportedInterfaceOrientations{
#ifdef __IPHONE_6_0
    return UIInterfaceOrientationMaskPortrait;
#endif
}
- (BOOL) shouldAutorotate {
    return NO;
}



2

if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
[[UIDevice currentDevice] performSelector:@selector(setOrientation:) 
  withObject:(id)UIInterfaceOrientationPortrait];
}
}
//但是
- (BOOL) shouldAutorotate {
    return NO;
}//一定要返回no



可以设置view与电池条方向保持一致

在AooController.mm中

<span style="font-size:18px;">- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions </span>

这个函数中加一句话

[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationPortrait animated: NO];


android项目修改为横屏的方法是修改xml文件:

打开项目中的AndroidManifest.xml文件中,

screenOrientation="landscape" 为横屏,
screenOrientation="portrait"为竖屏




cocos2dx如何设置ios和Android横屏竖屏的几种方法

原文:http://my.oschina.net/ffs/blog/309309

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!