🚀
🎉 限时福利:免费领$20会员

Comet AI浏览器 - 让搜索更智能 价值$20

革命性AI搜索体验,下载即送1个月Pro会员,邀请好友还能赚现金!

💎
1个月
Pro会员免费
💰
$5-$20
邀请奖励
下载注册即送价值$20的Pro会员
AI智能搜索,结果更精准更快速
邀请好友得现金:每人$5-$20奖励
朋友也获得1个月免费Pro会员
⚡ 点击即可领取 | 双赢机会不容错过

cocos2dx怎样设置ios和Android横屏竖屏的几种方法

cocos2d-x编译到ios上。默认是横屏的,若要改为http://竖屏。不同的ios版本号。方法也会不同

在ios7上或许我们设置好了横竖屏。但到了ios6上或许会变化。以下白白给大家分享一下我的做法

转载请注明地址http://blog.csdn.net/u010229677

1、通用的

仅仅须要在RootViewController.mm文件中面

- (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;
}


————也能够这么做—————

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


另外,须要在项目的General属性Deployment InfoPortrait前面选中

2、能够设置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中设置

android:screenOrientation="portrait"


posted @ 2015-12-21 21:35  mengfanrong  阅读(3989)  评论(0)    收藏  举报