@@ -56,6 +56,8 @@ extension ViewController {
}
override func collectionView(collectionView: UICollectionView, didEndDisplayingCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath) {
+
+ // This will cancel all unfinished downloading task when the cell disappearing.
(cell as! CollectionViewCell).cellImageView.kf_cancelDownloadTask()
@@ -274,6 +274,10 @@ public extension UIImageView {
extension UIImageView {
+ /**
+ Cancel the image download task bounded to the image view if it is running.
+ Nothing will happen if the downloading has already finished.
+ */
public func kf_cancelDownloadTask() {
kf_imageTask?.downloadTask?.cancel()