http://blog.csdn.net/kbawyg/article/details/8092946EGOImageView是一种实现网络图片的异步加载和缓存的第三方类库,具有相同功能的第三方类库还有SDWebImage。但是相比两个类库的安装和使用来说,EGOImageView更简单一些,下面就介绍一下EGOImageView的使用方法:
<wbr><wbr>1、下载EGOImageView及其相关的类库</wbr></wbr>
<wbr><wbr><wbr><a href="https://github.com/enormego/EGOImageLoading" target="_blank" style="text-decoration:none; color:rgb(62,115,160)">EGOImageLoading</a></wbr></wbr></wbr>
<wbr><wbr>将EGOCache、EGOImageButton、EGOImageView、EGOImageLoader全部添加到工程下(拷贝)</wbr></wbr>
<wbr><wbr>2、EGOImagView使用代码如下 <wbr><wbr></wbr></wbr></wbr></wbr>
-
EGOImageView<wbr>*imageView<wbr>=<wbr>[[EGOImageView<wbr>alloc]<wbr>initWithPlaceholderImage<wbr>:[UIImage<wbr>imageNamed:@"placeholder.png"]];<wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
-
imageView.imageURL<wbr>=<wbr>[NSURL<wbr>URLWithString:@"http://....../images/1.jpg"];<wbr><wbr></wbr></wbr></wbr></wbr></wbr>
-
imageView.frame<wbr>=<wbr>CGRectMake(x,x,x,x);<wbr><wbr></wbr></wbr></wbr></wbr>
-
[self.view<wbr>addSubView:imageView];<wbr><wbr></wbr></wbr></wbr>
<wbr style="color:rgb(70,70,70); font-family:simsun; font-size:14px; line-height:21px; text-align:left; background-color:rgb(188,211,229)"><span style="color:rgb(70,70,70); font-family:simsun; font-size:14px; line-height:21px; text-align:left; background-color:rgb(188,211,229)"></span><wbr style="color:rgb(70,70,70); font-family:simsun; font-size:14px; line-height:21px; text-align:left; background-color:rgb(188,211,229)"><span style="color:rgb(70,70,70); font-family:simsun; font-size:14px; line-height:21px; text-align:left; background-color:rgb(188,211,229)">placeholder.png</span><span style="color:rgb(70,70,70); font-family:simsun; font-size:14px; line-height:21px; text-align:left; background-color:rgb(188,211,229)">是加载图片未完成时显示的图片,当加载过程完成之后</span><span style="color:rgb(70,70,70); font-family:simsun; font-size:14px; line-height:21px; text-align:left; background-color:rgb(188,211,229)">就会显示url对应的图片。
</span><wbr style="color:rgb(70,70,70); font-family:simsun; font-size:14px; line-height:21px; text-align:left; background-color:rgb(188,211,229)"><span style="color:rgb(70,70,70); font-family:simsun; font-size:14px; line-height:21px; text-align:left; background-color:rgb(188,211,229)"></span><wbr style="color:rgb(70,70,70); font-family:simsun; font-size:14px; line-height:21px; text-align:left; background-color:rgb(188,211,229)"><span style="color:rgb(70,70,70); font-family:simsun; font-size:14px; line-height:21px; text-align:left; background-color:rgb(188,211,229)"></span><wbr style="color:rgb(70,70,70); font-family:simsun; font-size:14px; line-height:21px; text-align:left; background-color:rgb(188,211,229)"><span style="color:rgb(70,70,70); font-family:simsun; font-size:14px; line-height:21px; text-align:left; background-color:rgb(188,211,229)"></span>
<p style="margin-top:0px; margin-bottom:5px; padding-top:0px; padding-bottom:0px; border:0px; list-style:none; word-wrap:normal; word-break:normal; line-height:21px; color:rgb(70,70,70); font-family:simsun; font-size:14px; text-align:left; background-color:rgb(188,211,229)">
<br><wbr><wbr>3、需要特别注意的是EGOImageView的一个非常奇葩的Bug</wbr></wbr></p>
<p style="margin-top:0px; margin-bottom:5px; padding-top:0px; padding-bottom:0px; border:0px; list-style:none; word-wrap:normal; word-break:normal; line-height:21px; color:rgb(70,70,70); font-family:simsun; font-size:14px; text-align:left; background-color:rgb(188,211,229)">
<wbr><wbr>当imageView的图片加载完成了,这时你想换一个图片的url并用EGOImageView加载这个图片时,需要重新设置EGOImageView 的imageURL属性。但是这里要特别注意的是这个方法必须在主线程中执行,找到这个Bug我费了很大的劲,在用英文的Google搜索了好几页才找到 一位同是天涯沦落人的Coder,于是有了下面的代码</wbr></wbr></p>
<div style="color:rgb(70,70,70); font-family:simsun; font-size:14px; line-height:21px; text-align:left; background-color:rgb(188,211,229)">
<div><br></div>
<ol start="1" style="margin:0px; padding:0px; border:0px; list-style:none"><li style="margin:0px 0px 0px 30px; padding:0px; border:0px; list-style:decimal">
<span style="word-wrap:normal; word-break:normal">[imageView<wbr>performSelectorOnMainThr<wbr>ead:@selector(setImageURL:)<wbr>withObject:[NSURL<wbr>URLWithString:@"http://....../images/2.jpg"]<wbr>waitUntilDone:NO];</wbr></wbr></wbr></wbr></wbr></span>
</li></ol>
</div>
</wbr></wbr></wbr></wbr></wbr>
分享到:
相关推荐
NULL 博文链接:https://eric-gao.iteye.com/blog/1724252
本代码包含EGOImageView ,EGOImageLoader ,EGOImageButton, EGOImageCache,支持图片异步缓存加载
实现UITableView异步加载图片,类似于EGOImageView的效果。 而且自己写的代码比较清晰,容易理解,易于扩展。可以实现指定placehoderImage以及指定imageURL,来进行图片的异步加载。 同时,如果图片已经请求过,则...
异步下载图片 非常好用的一款第三方工具类
EGOImageView EGOTableViewPullRefresh MMDrawerController PZPhotoView 集成这四个控件的使用
关于图片加载用EGOImageView,实时加载显示的
基于EGOImageView扩展成的一个用于加载网络视频url的图片工具类(就是在自动加载网络图片的基础上,增加了自动加载视频的功能),可自己缓存视频文件,同时将视频的第一帧作为图像。
作者说:这份代码由于本人苦于EGOImageView 和EGOCache的少许bug,自己切实需要,才花时间写了这样一个ImageCacher类。优点如下: 1.借鉴EGOCache,将URL的hash码作为缓存文件的文件名,当服务器端URL发生变化的...