//此方法在进入应用和当屏幕旋转的额时候,会调用
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
if (self.direction == SuportDirectionRight) {
return UIInterfaceOrientationMaskLandscapeRight;
} else if (self.direction == SuportDirectionPortrait){
return UIInterfaceOrientationMaskPortrait;
} else {
return UIInterfaceOrientationMaskAll;
}
}
//这一步,是必须的,因为在进入目标的VC之后,需要回调上述的APPdelegate方法
AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate;
app.direction = SuportDirectionRight;
UIStoryboard *board = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
ViewController *VC = [board instantiateViewControllerWithIdentifier:@"ViewController"];
//必须将目标的VC设置为navigationVC,如果前一个VC为navigationVC就不用这一步
UINavigationController * nav = [[UINavigationController alloc] initWithRootViewController:VC];
nav.navigationBarHidden = YES;
[self presentViewController:nav animated:NO completion:^{
noCurrentVC = NO;
}];
- (BOOL)prefersStatusBarHidden {
return YES;
}
-(BOOL)shouldAutorotate {
return YES;
}
-(UIInterfaceOrientationMask)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscapeRight;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationLandscapeRight;
}
强制屏幕旋转
#pragma - mark 进入全屏
-(void)begainFullScreen {