在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 Info的Portrait前面選中
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"