AppDelegate中做下面几个方法
@property (nonatomic, assign) BOOL screenRotation;
+ (AppDelegate *)getAppdelegate;
/*----------------------------横屏--------------------------------------------*/
+ (AppDelegate *)getAppdelegate{
return (AppDelegate *)[UIApplication sharedApplication].delegate;
}
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
if (self.screenRotation){
return UIInterfaceOrientationMaskLandscapeRight;
}
return UIInterfaceOrientationMaskPortrait;
}
/*----------------------------end--------------------------------------------*/
然后强制横屏,这里是直接将手机强制横了过来。。。
- (void)old_fullView{
[AppDelegate getAppdelegate].screenRotation = true;
[[UIDevice currentDevice] setValue: [NSNumber numberWithInteger: UIInterfaceOrientationLandscapeRight] forKey:@"orientation"];
/***新方法***/
/*记录进入全屏前的parentView和frame*/
self.videoView.videoViewParentView = self.videoView.superview;
self.videoView.videoViewFrame = self.videoView.frame;
self.videoView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
[kAPP_Window addSubview:self.videoView];
}
- (void)old_backView{
[AppDelegate getAppdelegate].screenRotation = false;
[[UIDevice currentDevice] setValue: [NSNumber numberWithInteger: UIInterfaceOrientationPortrait] forKey:@"orientation"];
self.videoView.frame = self.videoView.videoViewFrame;
[self.videoView.videoViewParentView addSubview:self.videoView];
}