在 iPhone 上下载图像 - Facebook 是如何做到的?
Facebook 应用程序如何下载/显示照片库中的图像?它们似乎在不同的时间加载,这是否表明存在某种程度的线程?当然,应用程序不会产生 X 数量的线程(其中 X 是图片数量),因为这会导致性能问题?谁能启发我,因为我想在我的应用程序中使用类似的东西(我会定期下载大量照片并将它们显示在应用程序中,因此依次下载它们需要很长时间)。此外,这些照片会定期更改,因此下载一次并缓存并不是真正的选择。
是否有某种框架/解决方案可以帮助我实现类似于 Facebook 画廊的目标?
谢谢,
杰克
How does the Facebook app go about downloading/displaying the images in photo galleries? They appear to load in at varying times which would indicate some degree of threading? Surely the app doesn't spawn X amount of threads (where X is the number of pictures) as this would cause performance issues? Can anyone enlighten me as I would like to use something similar in my app (I will be regularly downloading a large amount of photos and displaying them in the app so downloading them one after another takes too long). Also, these photos change on a fairly regular basis so downloading once and cacheing isn't really an option.
Is there some kind of framework/solution around that might help me achieve something similar to Facebooks galleries?
Thanks,
Jack
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Facebook 应用程序用于执行此操作的代码已作为 the Three20 库 开源。此功能在 TTPhotoViewController 中提供。
The code the Facebook app uses to do this has been open-sourced as the three20 library. This functionality is provided in TTPhotoViewController.
查看 Apple 的 LazyTableImages 示例。图像是异步下载的,并且具有对它们应该显示的位置的引用。
Have a look at the LazyTableImages example from Apple. The images are downloaded asynchronously and have a reference back to where they are supposed to be displayed.
我建议您使用这个库,ASIHTTPRequest,它就像 NSURLRequest 的扩展版本。我一直使用它来异步下载图像以供稍后显示。它有一个很好的 CACHE 实现,可以节省应用程序的带宽和加载时间。
I would recommend you use this Library, ASIHTTPRequest, which is like an extended version of the NSURLRequest. I have been using it to download images for later display, asynchronously. It has a nice CACHE implementation which saves bandwidth and loading times on your app.