From c5e94788e59723d189642e8489423ea64271340b Mon Sep 17 00:00:00 2001
From: younger_times <841720330@qq.com>
Date: 星期三, 05 七月 2023 21:21:22 +0800
Subject: [PATCH] 新增

---
 WanPai/Base/BaseVC.swift |   37 +++++++++++++++----------------------
 1 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/WanPai/Base/BaseVC.swift b/WanPai/Base/BaseVC.swift
index 5c4eb5c..bae18a0 100644
--- a/WanPai/Base/BaseVC.swift
+++ b/WanPai/Base/BaseVC.swift
@@ -40,21 +40,6 @@
     }
 
     func setRx(){
-        NotificationCenter.default.rx.notification(UIDevice.orientationDidChangeNotification).take(until:self.rx.deallocated).subscribe {[weak self] _ in
-            let orient = UIDevice.current.orientation
-            var desc = ""
-//            switch orient {
-//                case .portrait :desc = Localized("屏幕正常竖向")
-//                case .portraitUpsideDown:desc = Localized("屏幕倒立")
-//                case .landscapeLeft:desc = Localized("屏幕左旋转")
-//                case .landscapeRight:desc = Localized("屏幕右旋转")
-//                default:break
-//            }
-
-            if !desc.isEmpty{
-                self?.receiverNotification(orient: orient, desc: desc)
-            }
-        }.disposed(by: disposeBag)
     }
 
     func setUI(){
@@ -85,16 +70,24 @@
         navigationController?.popViewController(animated: true)
     }
 
-
-    deinit {
-        LogInfo(String(format: "%@ 已释放", NSStringFromClass(self.classForCoder).components(separatedBy: ".").last!))
+    override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
+        coordinator.animate(alongsideTransition: { [weak self] (context) in
+            let orient = UIApplication.shared.statusBarOrientation
+            switch orient {
+            case .landscapeLeft, .landscapeRight:
+                //横屏时禁止左拽滑出
+                self?.navigationController?.interactivePopGestureRecognizer?.isEnabled = false
+            default:
+                //竖屏时允许左拽滑出
+                self?.navigationController?.interactivePopGestureRecognizer?.isEnabled = true
+            }
+        })
+        super.viewWillTransition(to: size, with: coordinator)
     }
 
 
-    /// 屏幕旋转:当设备方向改变,需要对UI进行重新布局,子类重写此方法
-    @objc open func receiverNotification(orient:UIDeviceOrientation,desc:String){
-        LogInfo(desc)
-        refreshUI()
+    deinit {
+        LogInfo(String(format: "%@ 已释放", NSStringFromClass(self.classForCoder).components(separatedBy: ".").last!))
     }
 
 }

--
Gitblit v1.7.1