Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/13.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不从url分配图像-下载的图像有0个像素_Ios_Swift_Uiimageview_Sdwebimage - Fatal编程技术网

Ios SDWebImage不从url分配图像-下载的图像有0个像素

Ios SDWebImage不从url分配图像-下载的图像有0个像素,ios,swift,uiimageview,sdwebimage,Ios,Swift,Uiimageview,Sdwebimage,这是我对UIImageView的简单扩展: extension UIImageView { func setImageWithUrl(url: String?) { setImageWithUrl(url, placeholder: nil) } private func setImageWithUrl(url: String?, placeholder: UIImage? = UIImage(), deleteCacheImage: Bool = false) { ima

这是我对
UIImageView
的简单扩展:

extension UIImageView {

func setImageWithUrl(url: String?) {
    setImageWithUrl(url, placeholder: nil)
}

private func setImageWithUrl(url: String?, placeholder: UIImage? = UIImage(), deleteCacheImage: Bool = false) {

    image = placeholder ?? image

    if let url = url {

        let activityIndicatorView = UIActivityIndicatorView(frame: CGRectMake(0, 0, CGRectGetWidth(frame), CGRectGetHeight(frame)))
        activityIndicatorView.hidden = false
        activityIndicatorView.color = UIColor.curiousBlue()

        addSubview(activityIndicatorView)
        bringSubviewToFront(activityIndicatorView)

        activityIndicatorView.startAnimating()

        let options = deleteCacheImage ? SDWebImageOptions.RefreshCached : SDWebImageOptions.LowPriority

        sd_setImageWithURL(NSURL(string: url), placeholderImage: placeholder, options: options, completed: { image, error, cache, url in

            activityIndicatorView.hidden = true
            activityIndicatorView.stopAnimating()
            activityIndicatorView.removeFromSuperview()
        })
    }
}
}
例如

但是块中的
image
nil
。为什么?它返回一个错误:

下载的图像有0个像素


我通过cocoapods获得了最新版本的
SDWebImage
3.7.5

找到了解决方案吗?