Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用SDWebImage和UIProgressView时获取exc_bad_访问错误代码_Ios_Swift_Uiprogressview_Sdwebimage - Fatal编程技术网

Ios 使用SDWebImage和UIProgressView时获取exc_bad_访问错误代码

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

我正在使用UICollectionView+SDWebImage显示图像网格。 在自定义单元格中,我定义了UIProgressView来显示进度条,以显示图像加载进度

这是我的密码:

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工作正常。它正在打印下载图像的完整部分。