哪个是在UIScrollview上显示缩略图图像的最佳方法(从服务器下载) [英] Which is the best method to display thumbnail images on UIScrollview (downloaded from server)

查看:100
本文介绍了哪个是在UIScrollview上显示缩略图图像的最佳方法(从服务器下载)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在UIScrollview上显示许多图像(缩略图)(如照片应用)。
所有图像都将从服务器下载。根据我的知识,显示几乎没有其他选择:

I want to show a number of images (as thumbnails) on the UIScrollview (like the Photos app). All the images will be downloaded from the server. To display, as per my knowledge, there are few alternatives:

1)通过创建UIImageviews然后将它们添加为主滚动视图上的子视图
2)通过子类化一个UIView类,然后在其上绘制图像
3)使用CATiledLayer类

1) By creating UIImageviews and then add them as subview on main scrollview 2) By subclassing a UIView class, and then draw images on it 3) Using CATiledLayer class

我想,第一种选择不够好,因为它不是最好的方法,当加载大量图像时;和第三替代更适合大图像。因为我只会得到一些小图片,所以在我的情况下,第二个替代品看起来最好。

I guess, the 1st alternative is not good enough as it is not best method, when loading large number of images; and 3rd alternate is more appropriate for large images. As I will be getting only small images, so the 2nd alternate seems best in my case.

请建议,我应该选择哪个选项。如果可行,请提供示例代码。

Please suggest, for which option I should go for. If feasible, please provide sample code.

非常感谢提前:)

推荐答案

我发布了一个专门针对这个问题的免费库:HJCache。我们已经在很多应用程序中使用它,包括我们的Facebook应用程序Focus for Facebook。它异步下载,缓存文件,在屏幕上重复时共享图像(例如来自同一个人的帖子具有相同的配置文件缩略图),当用户滚动浏览大型图像表时,自动管理以正确的顺序下载正确的图像集,并且很容易使用'加载下一个图像提前'设计全屏幕照片浏览。

I released a free library made specifically for this problem: HJCache.We've used it in a number of apps, including our Facebook app Focus for Facebook. It asynchronously downloads, caches in files, shares images when repeated on screen (eg posts from from the same person with same profile thumbnail), automatically manages downloading the correct set of images in the correct order when the user scrolls through a large table of images, and is easy to use with a 'load the next image ahead' design for full screen photo browsing.

http://www.markj.net/hjcache-iphone-image-cache/

这篇关于哪个是在UIScrollview上显示缩略图图像的最佳方法(从服务器下载)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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