简体   繁体   English

使用SDWebImage缓存图像

[英]using SDWebImage to cache Image

I'm very new to IOS development. 我对IOS开发非常陌生。 Now, I want to cache all my images I get back from my webservice. 现在,我想缓存从Web服务获取的所有图像。 I am saving all the urls in my core database. 我将所有URL保存在核心数据库中。 When I nee to fill a tableview I get the data from my core database, and put it in the tableview. 当我需要填充一个表格视图时,我从核心数据库中获取了数据,并将其放在表格视图中。 Now I want to cache this pictures. 现在我要缓存此图片。 After some google searching. 经过一些谷歌搜索。 I found the SDWebImage. 我找到了SDWebImage。

I'm using it at this way in my tableview. 我在表视图中以这种方式使用它。

[cell.img_Picture setImageWithURL:[NSURL URLWithString:news.url]
                        placeholderImage:[UIImage imageNamed:@"placeholder.png"]];

But it is not showing this image. 但是它没有显示此图像。 My imageview keeps blank. 我的imageview保持空白。 I imported the SDWebImage framework correctly and followed all the steps on the github page to install it. 我正确导入了SDWebImage框架,并按照github页上的所有步骤进行安装。

But can anybody tell me what I'm doing wrong ? 但是有人能告诉我我在做什么错吗?

Thanks in advance 提前致谢

So you don't even see the placeholder.png image? 因此,您甚至看不到placeholder.png图片? Do you actually have a placeholder.png image added to your project? 您实际上在项目中添加了placeholder.png图片吗?

Have you tried logging the url that you've retrieved and checking that it is in fact valid (plug it into your browser)? 您是否尝试过记录检索到的URL并检查它实际上是否有效(将其插入浏览器)?

NSLog(@"%@", news.url);

You could also try logging the frame of your image_view: 您还可以尝试记录image_view的框架:

NSLog(@"Cell Frame x: %f, y: %f, w: %f, h: %f", cell.img_Picture.origin.x, cell.img_Picture.origin.y, cell.img_Picture.size.width, cell.img_Picture.size.height);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM