标签:
下面是一个异步请求加载图片数据的样例
1
2
3
4
5
6
7
8
9
10
11
|
//定义NSURL //定义NSURLRequest let request: NSURLRequest = NSURLRequest ( URL :imgURL) //异步获取图片 NSURLConnection .sendAsynchronousRequest(request, queue: NSOperationQueue .mainQueue(), completionHandler: {(response: NSURLResponse !,data: NSData !,error: NSError !)-> Void in //将图片数据赋予UIImage let img= UIImage (data:data) self . BgImageView .image = img }) |
标签:
原文地址:http://www.cnblogs.com/Free-Thinker/p/4841053.html