JJSaccolo / UIActivityIndicator-for-SDWebImage

The easiest way to add a UIActivityView to your SDWebImage view
MIT License
817 stars 160 forks source link

Complete closure is called 4 times per image #25

Open confile opened 9 years ago

confile commented 9 years ago

I use the following code in an `init()`` constructor:

    if let url: NSURL = NSURL(string: previewCard.getImageUrls().getWithInt(0) as! String) {
      self.imageView?.setImageWithURL(url, placeholderImage: MGImage.imageWithColor(UIColor.clearColor()), options: SDWebImageOptions.RefreshCached, completed: { (image:UIImage!, error:NSError!, type:SDImageCacheType, loadUrl:NSURL!) -> Void in

        println("-------------- done")
        }, usingActivityIndicatorStyle: UIActivityIndicatorViewStyle.Gray)

    }

The console output is:

 println("-------------- done")
 println("-------------- done")
 println("-------------- done")
 println("-------------- done")

Why is the complete closure called four times? Is this a bug?

fatuhoku commented 9 years ago

I cannot verify this; but I have also found performance issues with this component in the past.

confile commented 9 years ago

@fatuhoku Do you have any workaround?

fatuhoku commented 9 years ago

No; I solved my performance issue by not simply not using UIActivityIndicator-for-SDWebImage at all! No indicator is better than slow scrolling.

confile commented 9 years ago

Which performance issues are you talking about. How many images did you use when you had issues?

fatuhoku commented 9 years ago

@confile I used NZCircularImageView inside of UICollectionViewCells. It loads this component. It made scrolling really really slow!