Explorar el Código

多次滑动闪退 fixed

Chris hace 5 años
padre
commit
4e48a9041b

+ 6 - 0
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/View/CommunityVideoCoverCollectionCell.swift

@@ -97,7 +97,13 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
         backgroundColor = UIColor.white
         setupViews()
         setupLayouts()
+    }
+    
+    // Neccessary - 清除待复用Cell原先的player
+    override func prepareForReuse() {
+        super.prepareForReuse()
         
+        videoPlayView.cancelLoading()
     }
     
     required init?(coder aDecoder: NSCoder) {

+ 7 - 0
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/View/CommunityVideoPlayView.swift

@@ -95,4 +95,11 @@ class CommunityVideoPlayView: UIView {
         }
     }
     
+    // 清除待复用Cell原先的player
+    func cancelLoading() {
+        player = nil
+        playerItem = nil
+        playerLayer.player = nil
+    }
+    
 }