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