Browse Source

内存泄露还有待完善

南鑫林 5 years ago
parent
commit
5239ead0e9

+ 3 - 0
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/Community/View/Cell/CardContent/PicVideo/CardContentPicVideoCollectionViewCell.swift

@@ -7,6 +7,7 @@
 //
 
 import UIKit
+import Kingfisher
 
 class CardContentPicVideoCollectionViewCell: UICollectionViewCell {
     class func cellWith(collectionView:UICollectionView,indexPath:IndexPath) -> CardContentPicVideoCollectionViewCell {
@@ -67,6 +68,8 @@ class CardContentPicVideoCollectionViewCell: UICollectionViewCell {
     var imgStr: String? {
         didSet {
             iconImageView.kf.setImage(with: kURLImage(name: imgStr ?? ""), placeholder: kImage(name: "default_pic"))
+            KingfisherManager.shared.cache.clearDiskCache()
+            KingfisherManager.shared.cache.clearMemoryCache()
         }
     }
     

+ 11 - 11
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/View/RecommendSimilarCell.swift

@@ -140,17 +140,17 @@ extension RecommendSimilarCell: UICollectionViewDelegateFlowLayout,UICollectionV
     }
     
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
-        let cell = SearchContentListCollectionCell.cellWith(collectionView: collectionView, indexPath: indexPath)
-        cell.communityPostDataModel = communityPostDataModels?[indexPath.row]
-//        cell.userClosure = {
-//            [weak self] in
-//            if cell.communityPostDataModel?.uid != UserModel.shared().getModel()?.uid {
-//                let vc = OtherPersonalCenterViewController()
-//                vc.uid = cell.communityPostDataModel?.uid ?? 0
-//                self?.findViewController().navigationController?.pushViewController(vc, animated: true)
-//            }
-//        }
-        return cell
+        weak var cell = SearchContentListCollectionCell.cellWith(collectionView: collectionView, indexPath: indexPath)
+        cell?.communityPostDataModel = communityPostDataModels?[indexPath.row]
+        cell?.userClosure = {
+            [weak self] in
+            if cell?.communityPostDataModel?.uid != UserModel.shared().getModel()?.uid {
+                let vc = OtherPersonalCenterViewController()
+                vc.uid = cell?.communityPostDataModel?.uid ?? 0
+                self?.findViewController().navigationController?.pushViewController(vc, animated: true)
+            }
+        }
+        return cell!
     }
     
     func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {