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

IOS通用的 android

只须要在RootViewController.mm文件里面 ios

1 app

- (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中 spa

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

这个函数中加一句话 orm

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


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

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

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

相关文章
相关标签/搜索