如何在Swift 3.0中使用SDWebImage完成块? [英] How to use completion block using SDWebImage in Swift 3.0?

查看:97
本文介绍了如何在Swift 3.0中使用SDWebImage完成块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 SDWebImage 下载图片。如果成功下载图像,我想进一步操作。

Am using SDWebImage to download image. I want to do further operation if image is downloaded successfully.

cell.appIcon.sd_setImage(with: url, placeholderImage: UIImage.init(named: "App-Default"), completed: {(image: UIImage!, error: NSError!, cacheType: SDImageCacheType, imageURL: URL!) -> Void in
      // Perform operation. 
})

但我收到错误:


无法将类型'(UIImage!,NSError!,SDImageCacheType,URL!) - > Void'的值转换为预期的参数类型'SDExternalCompletionBlock?'

Cannot convert value of type '(UIImage!, NSError!, SDImageCacheType, URL!) -> Void' to expected argument type 'SDExternalCompletionBlock?'


推荐答案

终于解决了。

cell.appIcon.sd_setImage(with: url!, placeholderImage: UIImage(named: "App-Default"),options: SDWebImageOptions(rawValue: 0), completed: { (image, error, cacheType, imageURL) in
 // Perform operation.
}) 

这篇关于如何在Swift 3.0中使用SDWebImage完成块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆