Ios 使用SDWebImage和UIProgressView时获取exc_bad_访问错误代码
我正在使用UICollectionView+SDWebImage显示图像网格。 在自定义单元格中,我定义了UIProgressView来显示进度条,以显示图像加载进度 这是我的密码:Ios 使用SDWebImage和UIProgressView时获取exc_bad_访问错误代码,ios,swift,uiprogressview,sdwebimage,Ios,Swift,Uiprogressview,Sdwebimage,我正在使用UICollectionView+SDWebImage显示图像网格。 在自定义单元格中,我定义了UIProgressView来显示进度条,以显示图像加载进度 这是我的密码: cell.ImageInCell.sd_setImageWithURL(NSURL.URLWithString("\(apifileurl)"),placeholderImage: previewimg.image, options: nil, progress: {(receivedSiz
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)
}
})
问题是当我滚动太快时,我收到了错误:
exc_错误_访问错误代码2
当我删除该行时:
cell.LoadingLine.setProgress(prog, animated: 1)
一切正常。
有人能帮我解决这个问题吗?谢谢。如果在调用setProgress之前运行NSLog\prog会发生什么?setProgress工作正常。它正在打印下载图像的完整部分。