简体   繁体   English

在iOS中从JSON异步加载图片

[英]Asynchronous Image loading from JSON in iOS

I have been trying to make images load from a JSON feed asynchronously, using AFNetworking. 我一直在尝试使用AFNetworking从JSON feed异步加载图像。 However every example with that library, or any others, seems to only load the images asynchronously, but not the links from the JSON feed for the images. 但是,每个带有该库的示例或其他任何示例似乎都仅异步加载图像,而不是来自JSON feed的图像链接。 As seen in the documentation for AFNetworking, nothing asynchronous is ever mentioned about the JSON feed. 如AFNetworking文档中所见,关于JSON提要,从未提及任何异步方法。

What I always end up being stuck with is loading 10-15 images at a time, then having to load more once the user gets down to the bottom of my UICollectionView. 我总是坚持每次只能加载10-15张图像,然后一旦用户进入我的UICollectionView底部时就不得不加载更多图像。 This takes time, since all 15 images have to be loaded from the JSON feed. 这需要时间,因为所有15张图片都必须从JSON Feed中加载。

Is there an example somewhere out there that I can actually follow? 有没有可以实际效仿的例子? If there is not, is there a better way to do infinite scroll other than scrollViewDidEndDecelerating? 如果没有,除了scrollViewDidEndDecelerating之外,还有没有更好的方法来进行无限滚动?

or is the point of the asynchronous image loading in afnetworking to load the the links from the json using an infinite scrolling method, and then load the images asynchronously after that point? 还是在afnetworking中异步图像加载的点是使用无限滚动方法从json加载链接,然后在该点之后异步加载图像?

I guess what I am looking for is a smooth infinite scroll with asynchronous image loading for my uicollectionview. 我猜我正在寻找的是平滑平滑的无限滚动,并为uicollectionview加载了异步图像。

您可以尝试AsyncImageView,查看我的答案,它可能非常适合您的需求。

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

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