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"



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM