swift 异步加载图片
import UIKit @UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
// Override point for customization after application launch.
self.window!.backgroundColor = UIColor.whiteColor() self.window!.rootViewController = RootViewController(); self.window!.makeKeyAndVisible()
return true
}
}
import UIKit
class RootViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let imageView = UIImageView.init(frame: UIScreen.mainScreen().bounds);
imageView.backgroundColor = UIColor.greenColor()
self.view.addSubview(imageView)
let url:NSURL = NSURL.init(string: "http://pic2.ooopic.com/11/86/60/84bOOOPIC13.jpg")!
let request:NSURLRequest = NSURLRequest(URL: url)
//异步加载图片
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue(), completionHandler:{ (response, data, error) -> Void in
let image = UIImage(data: data!)
imageView.image = image
})
}
}
swift 异步加载图片的更多相关文章
- swift 异步加载图片(第三方框架ImageLoader)
import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: ...
- 实例演示Android异步加载图片
本文给大家演示异步加载图片的分析过程.让大家了解异步加载图片的好处,以及如何更新UI.首先给出main.xml布局文件:简单来说就是 LinearLayout 布局,其下放了2个TextView和5个 ...
- 实例演示Android异步加载图片(转)
本文给大家演示异步加载图片的分析过程.让大家了解异步加载图片的好处,以及如何更新UI.首先给出main.xml布局文件:简单来说就是 LinearLayout 布局,其下放了2个TextView和5个 ...
- android listview 异步加载图片并防止错位
网上找了一张图, listview 异步加载图片之所以错位的根本原因是重用了 convertView 且有异步操作. 如果不重用 convertView 不会出现错位现象, 重用 convertVie ...
- [Android]异步加载图片,内存缓存,文件缓存,imageview显示图片时增加淡入淡出动画
以下内容为原创,欢迎转载,转载请注明 来自天天博客:http://www.cnblogs.com/tiantianbyconan/p/3574131.html 这个可以实现ImageView异步加载 ...
- ListView异步加载图片,完美实现图文混排
昨天参加一个面试,面试官让当场写一个类似于新闻列表的页面,文本数据和图片都从网络上获取,想起我还没写过ListView异步加载图片并实现图文混排效果的文章,so,今天就来写一下,介绍一下经验. Lis ...
- 软引用SoftReference异步加载图片
HashMap<String, SoftReference<Drawable>> imageCache 关于SoftReference这个类多少知道些机制,会用就ok了. 机制 ...
- Android之使用Android-AQuery异步加载图片(一)
第一节:转载地址(http://www.cnblogs.com/lee0oo0/archive/2012/10/25/2738299.html) // 必须实现AQuery这个类 AQuery aq ...
- Android中ListView异步加载图片错位、重复、闪烁问题分析及解决方案
我们在使用ListView异步加载图片的时候,在快速滑动或者网络不好的情况下,会出现图片错位.重复.闪烁等问题,其实这些问题总结起来就是一个问题,我们需要对这些问题进行ListView的优化. 比如L ...
随机推荐
- SVN配置管理(trunk、branches、tags)
利用SVN的分支,合理地管理项目代码 由于SVN固有的特点,目录在SVN中并没有特别的意义,但是这三个目录却在大多数开源项目中存在,这是因为这三个目录反映了软件开发的通常模式. trunk是主分支,是 ...
- 2016.05.04,英语,《Vocabulary Builder》Unit 22
acerb/acri: comes from the Latin adjective acer, meaning 'sharp' or 'sour'. acerbic: [ə'sɜːrbɪk] adj ...
- sql in查询排序
1.默认下,使用select xxx where in(xx,xx)查询,返回结果是按主键排序的,如果要按in()中值的排列顺序,可以这样做: select * from talbe where ...
- eclipse常用窗口和功能总结
1.左上角File按钮功能:最重要的导入import第三方项目,maven,git,general等. File->import File->properties按钮,显示项目的存储位置, ...
- 返回指定的VC
for (UIViewController *controller in self.navigationController.viewControllers) { if ([co ...
- windows下Gulp安装
目录: 1.安装nodejs2.使用命令行3.npm介绍4.选装cnpm5.全局安装gulp6.新建package.json文件7.本地安装gulp插件8.新建gulpfile.js文件9.运行gul ...
- SQuirreL 连接 hive
软件安装版本: hadoop-2.5.1 hbase-0.98.12.1-hadoop2 apache-hive-1.2.1-bin SQuirreL SQL Client3.7 集成步骤: 1. S ...
- terminal(终端),shell,tty,console(控制台)区别
原文地址 stackexchange:What is the exact difference between a 'terminal', a 'shell', a 'tty' and a 'con ...
- Python中dict的特点、更新dict、遍历dict
dict的第一个特点是查找速度快,无论dict有10个元素还是10万个元素,查找速度都一样.而list的查找速度随着元素增加而逐渐下降. 不过dict的查找速度快不是没有代价的,dict的缺点是占用内 ...
- SQL查询中关于索引使用的笔记
建表KeyLevelStat (无主键),2个索引: CREATE TABLE KeyLevelStat( [Date] [int] NOT NULL, [Num] [varchar](8), [R0 ...