无法设置完成 SDWebImageCompletionBlock swift 3.0
Can't set completion SDWebImageCompletionBlock swift 3.0
工作 swift 2.2 波纹管块。
AvtarImgview.setImageWith(URL(string: https://....), completed: { (image : UIImage!, error : NSError!, cacheType : SDImageCacheType,imageURL : URL!) -> Void in
if image != NSNotFound && image != nil
{
let cgref : CGImageRef? = image.cgImage
let cim: CIImage? = image.ciImage
if cgref == nil && cim == nil
{
self.AvtarImgview.image = UIImage(named: "iconNoImageDeal")
}
}else
{
self.AvtarImgview.image = UIImage(named: "iconNoImageDeal")
}
}, usingActivityIndicatorStyle: UIActivityIndicatorViewStyle.gray)
获取错误 swift 3.0:-
Cannot convert value of type '(UIImage!, NSError!, SDImageCacheType,
URL!) -> Void' to expected argument type 'SDWebImageCompletionBlock!'
哪位小伙伴可以帮我把这个块转换成swfit 3.0。
提前致谢。
试试这个代码:
let urlString = "https://...."
let url = URL(string: urlString)
imageView.contentMode = .scaleAspectFit
imageView.sd_setImage(with: url) { (image, error, imageCacheType, imageUrl) in
if image != nil {
print("image found")
}else
{
print("image not found")
}
}
工作 swift 2.2 波纹管块。
AvtarImgview.setImageWith(URL(string: https://....), completed: { (image : UIImage!, error : NSError!, cacheType : SDImageCacheType,imageURL : URL!) -> Void in
if image != NSNotFound && image != nil
{
let cgref : CGImageRef? = image.cgImage
let cim: CIImage? = image.ciImage
if cgref == nil && cim == nil
{
self.AvtarImgview.image = UIImage(named: "iconNoImageDeal")
}
}else
{
self.AvtarImgview.image = UIImage(named: "iconNoImageDeal")
}
}, usingActivityIndicatorStyle: UIActivityIndicatorViewStyle.gray)
获取错误 swift 3.0:-
Cannot convert value of type '(UIImage!, NSError!, SDImageCacheType, URL!) -> Void' to expected argument type 'SDWebImageCompletionBlock!'
哪位小伙伴可以帮我把这个块转换成swfit 3.0。
提前致谢。
试试这个代码:
let urlString = "https://...."
let url = URL(string: urlString)
imageView.contentMode = .scaleAspectFit
imageView.sd_setImage(with: url) { (image, error, imageCacheType, imageUrl) in
if image != nil {
print("image found")
}else
{
print("image not found")
}
}