工作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: -
无法转换类型'的值(UIImage!,NSError!,SDImageCacheType, 网址!) - > Void'到预期的参数类型'SDWebImageCompletionBlock!'
任何好友都可以帮我在swfit 3.0中转换这个块。
提前致谢。
答案 0 :(得分:3)
试试这段代码:
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")
}
}