Просмотр исходного кода

Merge pull request #134 from onevcat/fix/transition-callback-timing

Call completion handler when transition finished
Wei Wang 10 лет назад
Родитель
Сommit
d62b3a74c2
1 измененных файлов с 8 добавлено и 4 удалено
  1. 8 4
      Kingfisher/UIImageView+Kingfisher.swift

+ 8 - 4
Kingfisher/UIImageView+Kingfisher.swift

@@ -209,16 +209,20 @@ public extension UIImageView {
                                         options: transition.animationOptions, animations:
                                         { () -> Void in
                                             transition.animations?(sSelf, image!)
-                                        }, completion: transition.completion)
+                                        }, completion: {
+                                            finished in
+                                            transition.completion?(finished)
+                                            completionHandler?(image: image, error: error, cacheType: cacheType, imageURL: imageURL)
+                                        })
                             })
                         } else {
                             indicator?.stopAnimating()
                             sSelf.image = image;
+                            completionHandler?(image: image, error: error, cacheType: cacheType, imageURL: imageURL)
                         }
-                        
+                    } else {
+                        completionHandler?(image: image, error: error, cacheType: cacheType, imageURL: imageURL)
                     }
-                    
-                    completionHandler?(image: image, error: error, cacheType: cacheType, imageURL: imageURL)
                 }
             })