實現啟動後自動橫屏執行個體(相容sdk6.0以下):
1.代理修改
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0){ [[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationLandscapeLeft animated: NO]; } self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];if (nil==self.bootViewController) {self.bootViewController = [[BootViewController alloc] init];} //設定顯示方法,其他要添加上去的子控制視圖同理 if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0){ [self.window addSubview: self.bootViewController.view]; }else { [self.window setRootViewController:self.bootViewController]; } [self.window makeKeyAndVisible];}
2.子控制器實現橫屏旋轉
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {return YES;}return NO;}-(BOOL)shouldAutorotate{ return YES;}-(NSUInteger)supportedInterfaceOrientations{ return UIInterfaceOrientationMaskLandscapeLeft;}
//其他實現待續....