在iPhone应用程序中缓存图像 [英] Caching images in iPhone app

查看:59
本文介绍了在iPhone应用程序中缓存图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的iPhone应用程序具有内置的RSS阅读器.有图像,我想找到一种在系统上缓存它们的方法,但是让系统管理缓存并最终清理.

My iPhone app has a built in RSS reader. There are images and I'd like to find a way to cache them on the system but have the system manage the caching and eventual clean up.

有没有办法做到这一点?

Is there a way of doing this?

推荐答案

Three20 进行了不错的图像缓存.您不需要其余的内容,只需查看TTImageView即可,它是UIImageView的直接替代品.你只是做

Three20 does decent image caching. You don't need the rest of it, just look at TTImageView which is a drop-in replacement for UIImageView. You just do

someImageControl.urlPath = @"http://example.com/your/image.jpg";

然后TTImageView处理其余部分,包括在磁盘上进行缓存等.

And TTImageView handles the rest, including caching on disk etc.

我自己在使用此方法时只有两个小问题:

I only have two minor problems with this approach myself:

  • 由于某种原因,即使图像是有效的JPG/PNG,它似乎也无法加载所有图像格式.尚未调试.
  • 我不确定它如何处理清理部分.我注意到有些图像有时会从缓存中消失,并从网络中刷新,但这并没有打扰我进行调查.它有效".

TTImageView还有其他一些不错的属性,我不必浪费时间,例如,有一个占位符图像可以随您的应用一起提供,直到显示出从网络加载的真实图像为止.

TTImageView has some other nice properties that I don't have to waste my time on, e.g there is a placeholder image that you can ship with your app that is shown until the real image loads from network, etc.

这篇关于在iPhone应用程序中缓存图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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