如何加载带有一些默认图像的表,直到它从互联网 iPhone 获取原始图像?
我有一个 uitableview 将一张图像存储在一个单元格中。它的图像是从互联网加载的。问题是应用程序变得很慢,直到从互联网加载其图像为止。所以我想设置一种机制,它首先加载默认图像,当它获取原始图像时,默认图像将被原始图像替换。
给我任何教程或任何示例代码。
提前致谢。
I have a uitableview which stores one image in one cell. Its image get loaded from internet. The problem is the application get slow till its image get loaded from internet. So I want to put a mechanism that it first get loaded with a default image and when it gets the original then the default image will be replaced by the original one.
Give me any tutorial or any sample code for it.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
通过其他线程获取图像...并使用通知或委托来跟踪图像下载中的任何更改...假设您正在使用通知...然后在您设置为该通知的观察者的类中重新加载tableView 的数据 .... 因此您的表格图像将在默认图像的位置进行更新 .... 有关更多详细信息,让我们举个例子 ..... 创建一个操作类来下载我们称之为拇指的图像 .. ..在这个例子中我做了两个类
1.
PhotoGalleryVC
显示拇指列表以及每个拇指的一些详细信息2.
LoadGalleryThumbOp
[Op = 操作] 在 LoadGalleryThumbOp.m 中完成后下载拇指并发布通知,因为
此类将下载您想要的图像,并在下载图像时调用其委托。
使用它
现在是
PhotoGalleryVC
中的使用部分,在 .m 部分中,最后是下载特定图像时调用的方法
woooh.....!一个例子有很多代码
注意:我删掉了很多行,所以这段代码可能无法直接为你工作{可能有很多错误..},但我希望你能了解幕后的主要思想...:)
Get your image trough some other thread .... and use notification or delegate to keep track of any change in image download ... suppose you are using notification .... then in class which you set as observer for that notification reload the data of tableView .... so your table image will get updated where there was so default image .... for more detail lets take an example ..... Make a operation class to downloading the image we call it thumb .... In this example I make 2 classes
1.
PhotoGalleryVC
which shows a list of thumbs and some detail of each thumb and2.
LoadGalleryThumbOp
[Op = operation] downloads thumbs and post notification when donein LoadGalleryThumbOp.m do it as
this class will download the image you wanted and will call its delegate when the image is download ..
Now comes its use part in
PhotoGalleryVC
use it like thisin .m part
finally the method which is called when a particular image is downloaded
woooh.....! thats a lot of code for one example
Note : I cut out so many line so this code may not work for u directly {there may be so many errors .. }, But i hope you get the main idea behind the scene ... :)
这个示例代码很棒,它教会了我很多。
这使用了 ASIHttpRequest 框架,如果您要使用此技术,我建议您使用此处,因为示例代码中的版本现在已经很旧了。
此示例代码应该可以帮助您自定义单元格的委派等。
This sample code is great, It taught me a lot.
This uses the ASIHttpRequest framework, if you are going to use this technique, I recommend you use the latest version from here, because the version in the sample code is quite old now.
This sample code should help you with custom delegation of your cells etc.
根据上述情况,使用 LazyTableImages 总是更好。
此处给出的最佳示例
As per above scenario, its always better to use LazyTableImages.
The best example given here