gpt4 book ai didi

ios - 无法使用 SDWebImageManager 中的方法 downloadImageWithURL 缓存图像

转载 作者:行者123 更新时间:2023-11-28 16:13:55 24 4
gpt4 key购买 nike

我正在使用下面给出的代码使用 downloadImageWithURL 方法下载图像并将图像分配给 UIImageView 并使用 SDImageCache( ).storeImage,但我无法缓存图像。我错过了什么吗?

这是我的代码:

SDWebImageManager.sharedManager().downloadImageWithURL(profileImageURL,
options: SDWebImageOptions.HighPriority,
progress: { (min:Int, max:Int) -> Void in
})
{ (image:UIImage!, error:NSError!, cacheType:SDImageCacheType, finished:Bool, url:NSURL!) -> Void in
if (image != nil)
{
self.userProfilePic.image = image
SDImageCache.sharedImageCache().storeImage(image, forKey: "userProfilePicImage", toDisk: true)

}
}

最佳答案

查看github页面,有专门针对UIImageView的分类。在 https://github.com/rs/SDWebImage 上寻找 Using UIImageView+WebCache category with UITableView正如他们举的例子。

这既设置图像,缓存它,又在获取图像时使用占位符图像。

关于ios - 无法使用 SDWebImageManager 中的方法 downloadImageWithURL 缓存图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39287355/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com