sdwebimage

How to update image in cache when image changed on server with SDWebImage

為{幸葍}努か 提交于 2019-11-29 03:13:10
I am using SDWebImage library to download images from server. https://github.com/rs/SDWebImage SDWebImage not able update the cached image when image updated on server with the same url. SDWebImage does some caching by default, so it would be better to use a new URL if the image changes. So, for instance, if you have control over the URL and can change it every time the image has changed, you could do that. If that's not the case, try using SDWebImageRefreshCached in the options field in order to respect HTTP cache control headers, like this: [imageView setImageWithURL:[NSURL URLWithString:@

How to show an activity indicator in SDWebImage

我的未来我决定 提交于 2019-11-28 22:49:40
问题 Currently i am integrating SDWebImage in my project by following below things 1)#import "UIButton+WebCache.h" 2)[button setImageWithURL:url placeholderImage:[UIImage imageNamed:@"no_photo.png"]]; So it will show the list of image present in URL above the respective buttons. But Now i want to show an activity indicator above button when the image is getting downloaded ,So how can i do this? 回答1: Works like a charm for me : Swift 3: imgView.setShowActivityIndicator(true) imgView

你真的懂SDWebImage?

你说的曾经没有我的故事 提交于 2019-11-28 22:43:57
SDWebImage已经到了用烂了的地步,对于一名优秀的开发者来说,会用只是最简单的一步,我们要能够研究到其底层的技术实现和设计思路原理。在网上偶然间看到了一篇文章,感觉不错,略作修改,批注,后面的内容大家可以一起探讨~ 源码来源: https://github.com/rs/SDWebImage 版本: 3.7 SDWebImage是一个开源的第三方库,它提供了UIImageView的一个分类,以支持从远程服务器下载并缓存图片的功能。它具有以下功能(github上的自我介绍): 提供UIImageView的一个分类,以支持网络图片的加载与缓存管理 一个异步的图片加载器 一个异步的内存+磁盘图片缓存 支持GIF图片 支持WebP图片 后台图片解压缩处理 确保同一个URL的图片不被下载多次(操作队列) 确保虚假的URL不会被反复加载 确保下载及缓存时,主线程不被阻塞(写到磁盘时采用异步) 从github上对SDWebImage使用情况就可以看出,SDWebImage在图片下载及缓存的处理方面还是很被认可的。在本文中,我们主要从源码的角度来分析一下SDWebImage的实现机制。讨论的内容将主要集中在图片的下载及缓存,而不包含对GIF图片及WebP图片的支持操作。 一、下载 在SDWebImage中,图片的下载是由 SDWebImageDownloader 类来完成的

SDWebImage and setting custom HTTP headers?

给你一囗甜甜゛ 提交于 2019-11-28 21:20:15
I´ve just changed my code for caching images away from EGOImageCache to SDWebView. Unfortunately i don´t know how to set custom HTTP headers as i have to send authentification to be able to fetch images. It was easy done with EGOImageCache as i´ve extended the NSURLRequest at the appropriate place. But i don´t know how to do that with the SDWebView.framework. I see the headers and i´ve found methods in SDWebImageDownloader.h containing /** * Set a value for a HTTP header to be appended to each download HTTP request. * * @param value The value for the header field. Use `nil` value to remove the

SDWebImage Download image and store to cache for key

China☆狼群 提交于 2019-11-28 20:08:58
问题 Hello I am using the SDWebImage framework in a project and I want to download and cache images, but I think my code is storing an image in the cache twice? Is there any way to store the image in the cache by a key only once? Here is my code. SDWebImageManager *manager = [SDWebImageManager sharedManager]; [manager downloadWithURL:[NSURL URLWithString:url] options:0 progress:^(NSUInteger receivedSize, long long expectedSize) { } completed:^(UIImage *image, NSError *error, SDImageCacheType

SDWebImage clearing cache

假如想象 提交于 2019-11-28 18:37:05
I'm displaying a list of icons downloaded from the web with text in a table view. The icons can be changed on server side and I need to replace them as soon as new icons are getting available. I try using the following code: [imgView setImageWithURL:url placeholderImage:[UIImage imageNamed:@"table_avatar_icon"] options:SDWebImageCacheMemoryOnly]; And call [[SDImageCache sharedImageCache] clearMemory]; In my refresh callback, but it does not purge the contents of the cache. More to it, even if I close the application and open it again the image is still there. I found only one way to clear the

SDWebImage process images before caching

偶尔善良 提交于 2019-11-28 18:28:29
I fetch a lot of images from the web, and they are all kind of sizes - they can be big, small etc.. So I can resize them when I display them in the cell but this is inefficient. It's way better to resize them after SDWebImage have download them and cache them resized, instead of storing large images on disk and resize them for every cell. So how can I do this with SDWebImage, or I have to hack a bit onto the class? I had the same problem as you, and tried tweaking SDWebImage first, but ended up building my own component that solved the problem. You can take take a look at it here : https:/

SDWebImage does not load remote images until scroll

隐身守侯 提交于 2019-11-28 17:39:43
I am using SDWebImage library to load remote images into a table view which uses a custom cell class i have created. I simply use [cell.imageView setImageWithURL:url placeholderImage:[UIImage imageNamed:@"loading.jpg"]]; in cellForRowAtIndexPath: Now the problem is it loads images in the visible cells only and not for cells that are offscreen for which i have to scroll up and down to make them load. Is there any way i can load all images without having to scroll the table view. Thanks in advance!! If you want to prefetch rows, you can respond to UIScrollViewDelegate methods to determine when

Using '!' here is deprecated and will be removed in a future release - swift 4.2

半世苍凉 提交于 2019-11-28 13:05:11
Compiler throwing following warning when setting image in a cell using SDWebimage in Swift 4.2. Swift Compiler warning : Using '!' here is deprecated and will be removed in a future release let url = NSURL(string: (str_url) as String) cell.img!.sd_setImage(with: url as URL!, completed: block_image) //--- WARNING ON THIS LINE AT URL! Any Suggestions ? Use this code : cell. img!.sd_setImage(with: url! as URL, completed: block_image) Suggestion: use URL instead of NSURL let url = URL(string: "" ) //use url String cell.img!.sd_setImage(with: url, completed: block_image) Try this: if let url = URL

Dynamic cell height with SDWebImage

不羁的心 提交于 2019-11-28 12:54:18
I have a table view and table view cells with an image view on them. I want them to have a fixed width but with a dynamic height (depending on the image coming in from the server). I am using SDWebImage to download and set the image, but the table view cells are turning out very weird. I didn't forget to: postTableView.estimatedRowHeight = UITableViewAutomaticDimension postTableView.rowHeight = UITableViewAutomaticDimension cellForRow method: func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: