Type One
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarOrientationChange:)name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
- (void)statusBarOrientationChange:(id)sender{
self.navigationController.navigationBar.hidden = NO;
UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
if (orientation == UIDeviceOrientationPortraitUpsideDown ) {
self.playerView.frame = CGRectMake(0,0, ScreenWidth, AREA_HEIGHT(422));
[self.view updateConstraints];
};
}
Type Two
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (nonatomic, assign) BOOL allowRotation;
@end
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(nullable UIWindow *)window{
if (_allowRotation == YES) {
UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
if (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight) {
return UIInterfaceOrientationMaskLandscape;
}else {
return UIInterfaceOrientationMaskPortrait;
}
}else{
return (UIInterfaceOrientationMaskPortrait);
}
}
Type Three
@implementation UINavigationController (VideoPlay)
-(BOOL)shouldAutorotate {
return [[self.viewControllers lastObject] shouldAutorotate];
}
-(NSUInteger)supportedInterfaceOrientations {
return [[self.viewControllers lastObject] supportedInterfaceOrientations];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
}
@end