|
@@ -4,11 +4,11 @@
|
|
|
//
|
|
|
// Created by ak on 2021/6/2.
|
|
|
//
|
|
|
-
|
|
|
+
|
|
|
import Alamofire
|
|
|
-import UIKit
|
|
|
-import NXFramework_Swift
|
|
|
import BFFramework
|
|
|
+import NXFramework_Swift
|
|
|
+import UIKit
|
|
|
public class MVBaseController: UIViewController, UIGestureRecognizerDelegate {
|
|
|
// 侧滑拦截返回
|
|
|
public var popGestureHandle: (() -> Void)?
|
|
@@ -23,17 +23,15 @@ public class MVBaseController: UIViewController, UIGestureRecognizerDelegate {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- lazy public var manager: NetworkReachabilityManager? = {
|
|
|
+ public lazy var manager: NetworkReachabilityManager? = {
|
|
|
let manager = NetworkReachabilityManager(host: "www.baidu.com")
|
|
|
manager?.listener = { status in
|
|
|
- if status == .reachable(.wwan) || status == .reachable(.ethernetOrWiFi) {
|
|
|
-
|
|
|
- }
|
|
|
+ if status == .reachable(.wwan) || status == .reachable(.ethernetOrWiFi) {}
|
|
|
}
|
|
|
return manager
|
|
|
}()
|
|
|
|
|
|
- override public func viewDidLoad() {
|
|
|
+ override public func viewDidLoad() {
|
|
|
super.viewDidLoad()
|
|
|
navigationController?.isNavigationBarHidden = true
|
|
|
view.backgroundColor = UIColor.white
|
|
@@ -43,7 +41,7 @@ public class MVBaseController: UIViewController, UIGestureRecognizerDelegate {
|
|
|
navHeadImageView?.backgroundColor = UIColor.white
|
|
|
navHeadImageView?.frame = CGRect(x: 0, y: 0, width: cScreenWidth, height: cDevice_iPhoneNavBarAndStatusBarHei)
|
|
|
view.addSubview(navHeadImageView!)
|
|
|
-
|
|
|
+
|
|
|
UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)
|
|
|
automaticallyAdjustsScrollViewInsets = false
|
|
|
navigationController?.interactivePopGestureRecognizer?.delegate = self
|
|
@@ -52,7 +50,6 @@ public class MVBaseController: UIViewController, UIGestureRecognizerDelegate {
|
|
|
|
|
|
public func hiddenNavigation() {
|
|
|
navHeadImageView?.isHidden = true
|
|
|
-
|
|
|
}
|
|
|
|
|
|
func showNavigation() {
|
|
@@ -71,7 +68,7 @@ public class MVBaseController: UIViewController, UIGestureRecognizerDelegate {
|
|
|
let leftButton = UIButton(type: .custom)
|
|
|
leftButton.frame = CGRect(x: 0, y: cDevice_iPhoneStatusBarHei, width: cDefaultMargin * 4, height: cDefaultMargin * 4)
|
|
|
leftButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: -5, right: 0)
|
|
|
- leftButton.setImage(UIImage(named: image ?? "icon_detail_back"), for: .normal)
|
|
|
+ leftButton.setImage(UIImage(named: image ?? "icon_detail_back"), for: .normal)
|
|
|
leftButton.addTarget(self, action: #selector(backBtnClick), for: .touchUpInside)
|
|
|
navHeadImageView?.addSubview(leftButton)
|
|
|
backButton = leftButton
|
|
@@ -114,22 +111,25 @@ public class MVBaseController: UIViewController, UIGestureRecognizerDelegate {
|
|
|
@objc func rightBtnClick(sender _: UIButton) {}
|
|
|
|
|
|
@objc func backBtnClick() {
|
|
|
- navigationController?.popViewController(animated: true)
|
|
|
+ if navigationController != nil {
|
|
|
+ navigationController?.popViewController(animated: true)
|
|
|
+ } else {
|
|
|
+ dismiss(animated: true, completion: nil)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- public override func viewDidAppear(_ animated: Bool) {
|
|
|
+ override public func viewDidAppear(_ animated: Bool) {
|
|
|
super.viewDidAppear(animated)
|
|
|
-
|
|
|
}
|
|
|
|
|
|
- public override func viewWillDisappear(_ animated: Bool) {
|
|
|
+ override public func viewWillDisappear(_ animated: Bool) {
|
|
|
super.viewWillDisappear(animated)
|
|
|
// PQLoadingHUB.shared.dismissHUB()
|
|
|
}
|
|
|
|
|
|
- public override func viewDidDisappear(_ animated: Bool) {
|
|
|
+ override public func viewDidDisappear(_ animated: Bool) {
|
|
|
super.viewDidDisappear(animated)
|
|
|
-
|
|
|
+
|
|
|
if view.viewWithTag(cGuideTag) != nil {
|
|
|
view.viewWithTag(cGuideTag)?.removeFromSuperview()
|
|
|
}
|
|
@@ -140,7 +140,7 @@ public class MVBaseController: UIViewController, UIGestureRecognizerDelegate {
|
|
|
BFLog(message: "\(String(describing: type(of: self)))被销毁")
|
|
|
}
|
|
|
|
|
|
- public override var preferredStatusBarStyle: UIStatusBarStyle {
|
|
|
+ override public var preferredStatusBarStyle: UIStatusBarStyle {
|
|
|
if #available(iOS 13.0, *) {
|
|
|
return .darkContent
|
|
|
} else {
|
|
@@ -149,7 +149,7 @@ public class MVBaseController: UIViewController, UIGestureRecognizerDelegate {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public override var prefersStatusBarHidden: Bool {
|
|
|
+ override public var prefersStatusBarHidden: Bool {
|
|
|
return isHiddenStatus
|
|
|
}
|
|
|
|