有没有什么理由我们不使用UIImageView的子类? [英] Is there any reason why we don't use subclasses of UIImageView?

查看:150
本文介绍了有没有什么理由我们不使用UIImageView的子类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建UIImageView的子类,以使其从服务器异步下载其图像;)

I'm currently trying to create a subclass of UIImageView in order to make it download its image from server asynchronously ;)

我试图自己做,我还没走得很远:D

I tried to do it by myself but I haven't gone very far yet :D

无论如何,我环顾四周,发现这一点:

Anyway, I looked around here and found this :

AsyncImageDownload

我看了一下代码,首先想到的是:为什么子类化UIView而不是UIImageView?

I had a look at the code and the first which springs to mind is : why subclassing a UIView and not a UIImageView ?!?

任何想法?

Cheers mates,

Cheers mates,

Gotye。

推荐答案

它是子类化UIView的原因是,例如,您应该在下载映像时显示UIActivityIndi​​cator。他们在他们的例子中并没有显示出来,但是我使用了这个代码,这真的很好。另外看看这篇文章的评论,你会发现更多的代码示例,还包括一些缓存和好东西。

The reason it is subclassing UIView is so that you should, for example, display a UIActivityIndicator while the image is being downloaded. They do not show this in their example but I have used this code and it is really good. Also look at the comments for this post you will find more code examples, also including some caching and nice stuff.

看看Wayne ,//www.markj.net/iphone-asynchronous-table-image/comment-page-1/#commentsrel =nofollow noreferrer他的YellowJacket.zip代码是非常好的。

Take a look at Wayne Cochra's comment. His YellowJacket.zip code is very nice.

这篇关于有没有什么理由我们不使用UIImageView的子类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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