易异步图像下载的UIImage查看 [英] Easy Asynchronous Image Download UIImage View

查看:74
本文介绍了易异步图像下载的UIImage查看的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序我建立它工作正常,但我现在用的图像源是从一个网站,当我切换回我的初步看法它需要相当长的一段时间,它加载。我的问题是会有完成这件事,并有速度更快的方式。
这里是code我用拉我的图像源

I have an app i am building it works fine but the image source i am using is from a website and when I switch back to my initial view it takes quite some time for it to load. My question is would there be a way to get this done and have the speed be faster. here is the code I use to pull my image source

////Loads UIImageView from URL
todaysWallpaper.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.inkdryercreative.com/daily/archive/mondays/images/062-mondays-960x640-A.jpg"]]];

任何帮助或在正确的方向上推。不久,图像会改变每一天的时间,以及等等,任何帮助/想法会有很大的AP preciation。

any help or a shove in the proper direction. Soon the image will change every time day as well so any help/thoughts on that would be of great appreciation.

推荐答案

这里的probleme是 dataWithContentsOfURL:是在主线程上,所以它会阻止你的UI时图像被下载。

The probleme here is that dataWithContentsOfURL: is on the main thread, so it will block your UI when the image is downloaded.

您必须异步下载。对于我个人使用很大的一块code的我在互联网上找到: SDWebImage 。它不正是你想要的。

You have to download it asynchronously. For that I personally use a great piece of code i found on the internet : SDWebImage. It does exactly what you want.

这篇关于易异步图像下载的UIImage查看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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