Browse Source

1.代码逻辑优化

huangxiaodong 1 year ago
parent
commit
7bc20b24ae

+ 1 - 48
创维盒子/双子星云手机/CloudPlayerWebRtc/WebRtcPlayerViewController.m

@@ -87,12 +87,10 @@
     
     
     if (rotation == 0) {
     if (rotation == 0) {
         self.isLan = NO;
         self.isLan = NO;
-        //[self setDeviceOrientation:(UIDeviceOrientationPortrait)];/*横屏处理*/
         [horizontalScreenTool setCurScreenIsHorizontaltype:NO];
         [horizontalScreenTool setCurScreenIsHorizontaltype:NO];
     } else {
     } else {
         self.isLan = YES;
         self.isLan = YES;
         [horizontalScreenTool setCurScreenIsHorizontaltype:YES];
         [horizontalScreenTool setCurScreenIsHorizontaltype:YES];
-        //[self setDeviceOrientation:(UIDeviceOrientationLandscapeLeft)];/*横屏处理*/
     }
     }
     
     
     if (@available(iOS 16,*)){
     if (@available(iOS 16,*)){
@@ -126,51 +124,6 @@
     return UIInterfaceOrientationMaskAll;
     return UIInterfaceOrientationMaskAll;
 }
 }
 
 
-/**
-// * @brief 设置屏幕方向
-// */
-- (void)setDeviceOrientation:(UIDeviceOrientation)orientationPortrait{
-    dispatch_async(dispatch_get_main_queue(), ^{
-        UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
-        //isPortraitMode
-        BOOL ScreenMode = ((UIDeviceOrientation)orientation == orientationPortrait);/*设置的屏幕方向是否与当前的屏幕方向一致*/
-        NSNumber *value = nil;
-        
-        AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate;
-        app.allowAutoRotate = YES;
-        
-        if (ScreenMode){}/*方向一致直接返回无需处理*/
-        else{
-            self->_canRate = YES;/*关键点  设置临时允许*/
-            if (@available(iOS 16,*)){
-                UIInterfaceOrientationMask  faceOrientationMask = UIInterfaceOrientationMaskLandscapeLeft;
-                if(UIDeviceOrientationPortrait == orientationPortrait){
-                    faceOrientationMask = UIInterfaceOrientationMaskPortrait;
-                }
-                
-                
-                NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects];
-                UIWindowScene *ws = (UIWindowScene *)array[0];
-                UIWindowSceneGeometryPreferencesIOS *geometryPreferences = [[UIWindowSceneGeometryPreferencesIOS alloc] init];
-                geometryPreferences.interfaceOrientations = faceOrientationMask;
-                [ws requestGeometryUpdateWithPreferences:geometryPreferences
-                                            errorHandler:^(NSError * _Nonnull error) {
-                    //业务代码
-                }];
-
-                [self setNeedsUpdateOfSupportedInterfaceOrientations];
-                
-            }
-            else{
-                value = [NSNumber numberWithInteger:orientationPortrait];//横竖屏值设置
-                
-                [[UIDevice currentDevice] setValue:value forKey:@"orientation"];/*先将状态栏旋转(影响系统通知弹框方向)*/
-                [[NSNotificationCenter defaultCenter] postNotificationName:UIDeviceOrientationDidChangeNotification object:nil];/*发送通知*/
-            }
-        }
-    });
-}
-
 - (void)viewDidLoad
 - (void)viewDidLoad
 {
 {
     [super viewDidLoad];
     [super viewDidLoad];
@@ -192,7 +145,7 @@
     AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate;
     AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate;
     app.isInPlayer = NO;
     app.isInPlayer = NO;
     app.allowAutoRotate = NO;
     app.allowAutoRotate = NO;
-    [self setDeviceOrientation:(UIDeviceOrientationPortrait)];/*横屏处理*/
+    [horizontalScreenTool setCurScreenIsHorizontaltype:NO];
     [super viewWillDisappear:animated];
     [super viewWillDisappear:animated];
     
     
     // 屏幕常亮
     // 屏幕常亮