SDWebImage does not assign an image with url - The uploaded image has 0 pixels

This is my simple extension for 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() }) } } } 

Example image .

but image in the nil block. What for? It returns an error:

The uploaded image has 0 pixels.

I have the latest version of SDWebImage , via cocoapods: 3.7.5 .

+5
source share

Source: https://habr.com/ru/post/1242898/


All Articles