Forráskód Böngészése

处理内存问题

jsonwang 3 éve
szülő
commit
f18695ee90

+ 16 - 19
BFFramework/Classes/Stuckpoint/View/PQStuckPointLoadingView.swift

@@ -12,19 +12,15 @@ import BFCommonKit
 
 class PQStuckPointLoadingView: UIView {
     var cancelHandle: ((_ sender: UIButton) -> Void)?
+    
     /// 同步进度显示
-    lazy var loadingView: UIImageView = {
-        let loadingView = UIImageView()
-        loadingView.tintColor = UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue)
-        let data = try? Data(contentsOf: URL(fileURLWithPath: currentBundlePath()!.path(forResource: "stuckPoint_edit_loading", ofType: ".gif")!))
-        if data != nil {
-            PQPHAssetVideoParaseUtil.parasGIFImage(data: data!, isRenderingColor: UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue)) { _, images, duration in
-                loadingView.displayGIF(data: nil, images: images, repeatCount: .max, duration: duration ?? 2)
-            }
-        }
-        return loadingView
+    lazy var loadingView: AnimatedImageView = {
+        let videoLoadingView = AnimatedImageView()
+        videoLoadingView.kf.setImage(with: URL(fileURLWithPath: Bundle.main.path(forResource: "stuckPoint_edit_loading", ofType: ".gif")!))
+        videoLoadingView.stopAnimating()
+        return videoLoadingView
     }()
-
+ 
     lazy var navBarLeftBtn: UIButton = {
         let navBarLeftBtn = UIButton(type: .custom)
         navBarLeftBtn.frame = CGRect(x: 0, y: cDevice_iPhoneStatusBarHei, width: cDefaultMargin * 4, height: cDefaultMargin * 4)
@@ -42,6 +38,7 @@ class PQStuckPointLoadingView: UIView {
         addSubViews()
         addLayout()
         
+        loadingView.startAnimating()
     }
     
     required init?(coder _: NSCoder) {
@@ -74,21 +71,21 @@ class PQStuckPointLoadingView: UIView {
         if self.superview != nil {
             return
         }
-        UIApplication.shared.keyWindow?.addSubview(self)
-        let data = try? Data(contentsOf: URL(fileURLWithPath: currentBundlePath()!.path(forResource: "stuckPoint_edit_loading", ofType: ".gif")!))
-        if data != nil {
-            PQPHAssetVideoParaseUtil.parasGIFImage(data: data!, isRenderingColor: UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue)) { _, images, duration in
-                self.loadingView.displayGIF(data: nil, images: images, repeatCount: .max, duration: duration ?? 2)
-            }
-        }
+ 
     }
 
     /// 移除视图
     /// - Returns: <#description#>
     func removeMarskView() {
+        loadingView.stopAnimating()
+        loadingView.layer.removeAllAnimations()
+        loadingView.removeFromSuperview()
+     
         if self.superview != nil {
             removeFromSuperview()            
         }
+      
+        BFLog(message: "removeMarskViewremoveMarskViewremoveMarskViewremoveMarskView")
     }
 
     @objc func cancelDownload(sender: UIButton) {
@@ -99,6 +96,6 @@ class PQStuckPointLoadingView: UIView {
     }
 
     deinit {
-        BFLog(message: "销毁加载中视图")
+        BFLog(message: "销毁加载中视图1111111")
     }
 }