I'm using UICollectionView + SDWebImage to display image grid. In custom cell, i defined UIProgressView to display progress bar for display image loading progress.
Here is my code:
cell.ImageInCell.sd_setImageWithURL(NSURL.URLWithString("\(apifileurl)"),placeholderImage: previewimg.image, options: nil,
progress: {(receivedSize: Int,expectedSize: Int) in
var prog:Float = Float(receivedSize)/Float(expectedSize)
cell.LoadingLine.setProgress(prog, animated: 1)
}, completed: {(image: UIImage?,error: NSError?,cacheType: SDImageCacheType,imageURL: NSURL?) in
if( image != nil ) {
cell.LoadingLine.setProgress(0, animated: 0)
}
})
Trouble is when i scroll too fast, i received error: exc_bad_access error code 2.
When i removed line:
cell.LoadingLine.setProgress(prog, animated: 1)
Everything work fine. Can anyone help me solve this problem? Thanks.