uiimageview 异步加载图片
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){
NSURL *url = [NSURL URLWithString: detailedActivity.pictures];
NSData *data = [[NSData alloc] initWithContentsOfURL:url];
dispatch_async(dispatch_get_main_queue(), ^(void){
self.activityImageView.image = [[UIImage alloc]initWithData:data];
});
});
本文转载至 http://stackoverflow.com/questions/16663618/async-image-loading-from-url-inside-a-uitableview-cell-image-changes-to-wrong

|
I've written two ways to async load pictures inside my UITableView cell. In both cases the image will load fine but when I'll scroll the table the images will change a few times until the scroll will end and the image will go back to the right image. I have no idea why this is happening.
... ...
|
|||||||||||||||||||||
|
|
Assuming you're looking for a quick tactical fix, what you need to do is make sure the cell image is initialized and also that the cell's row is still visible, e.g.:
The above code addresses two problems stemming from the fact that the cell is reused:
An even better fix, though, is to use a These If you want, you can write your own imageview category, but it's a lot of work, and |
|||||||||||||||||||||
|
uiimageview 异步加载图片的更多相关文章
- swift 异步加载图片(第三方框架ImageLoader)
import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: ...
- swift 异步加载图片
import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: ...
- UIImageView异步加载网络图片
在iOS开发过程中,经常会遇到使用UIImageView展现来自网络的图片的情况,最简单的做法如下: 去下载https://github.com/rs/SDWebImage放进你的工程里,加入头文件# ...
- 多线程异步加载图片async_pictures
异步加载图片 目标:在表格中异步加载网络图片 目的: 模拟 SDWebImage 基本功能实现 理解 SDWebImage 的底层实现机制 SDWebImage 是非常著名的网络图片处理框架,目前国内 ...
- 模仿SDWebImage实现异步加载图片
模仿SDWebImage实现异步加载图片 SDWebImage想必大家都不陌生吧,要实现它的图片异步加载功能这个还是很简单的. 注意:此处我只实现了异步加载图片,并没有将文件缓存到本地的打算哦:) 源 ...
- ios UITableView 异步加载图片并防止错位
UITableView 重用 UITableViewCell 并异步加载图片时会出现图片错乱的情况 对错位原因不明白的同学请参考我的另外一篇随笔:http://www.cnblogs.com/lesl ...
- IOS中UITableView异步加载图片的实现
本文转载至 http://blog.csdn.net/enuola/article/details/8639404 最近做一个项目,需要用到UITableView异步加载图片的例子,看到网上有一个E ...
- 实例演示Android异步加载图片
本文给大家演示异步加载图片的分析过程.让大家了解异步加载图片的好处,以及如何更新UI.首先给出main.xml布局文件:简单来说就是 LinearLayout 布局,其下放了2个TextView和5个 ...
- 实例演示Android异步加载图片(转)
本文给大家演示异步加载图片的分析过程.让大家了解异步加载图片的好处,以及如何更新UI.首先给出main.xml布局文件:简单来说就是 LinearLayout 布局,其下放了2个TextView和5个 ...
随机推荐
- PHP 友好的dump
/** * 浏览器友好的变量输出 * @param mixed $var 变量 * @param boolean $echo 是否输出 默认为True 如果为false 则返回输出字符串 * @par ...
- phpexcel导出乱码
在输出到浏览器时,要在head前加ob_end_clean();参考此文, ob_end_clean(); header('Content-Type: application/vnd.ms-excel ...
- exit和wait一起可以彻底清除子进程的资源
#include<stdio.h> #include<unistd.h> #include<sys/types.h> #include<stdlib.h> ...
- IOS中摇一摇实现截屏(可实现问题反馈的功能)
有一段时间没有更新博客了,今天更新一篇关于最近工作中用到的一个功能,先简单描述一下:我们知道,测试人员在测试客户端产品时,当出现问题或者BUG的时候,都得先对页面截图,然后从相册中选择截图,加上一段描 ...
- Spring引入配置文件
1.spring.xml加载映射的配置配置文件 <!--采用这种方式简化配置文件--> <context:property-placeholder location="cl ...
- sed: 1: “…”: invalid command code on Mac OS
昨天因为项目中有很多文件的同一个变量需要批量替换成另一个,想用sed做这个.Linux 这样其实就可以了 ~# sed -i “s/string_old/string_new/g” grep -rl ...
- iOS边练边学--自定义等高的cell
一.storyboard自定义cell <1>创建一个继承自UITableViewCell的子类,比如ChaosDealCell <2>在storyboard中 <2.1 ...
- iOS边练边学--view的封装
一.view封装的思路: *如果一个view内部的子控件比较多,一般会考虑自定义一个view,把它内部的子控件的创建屏蔽起来,不让外界关心 *外界可以传入对应的模型数据给view,view拿到模型数据 ...
- form_tag
class SwitchesController < ApplicationController #before_filter :authenticate_user!, :except => ...
- udp编程中,一次能发送多少个bytes为好?
在进行UDP编程的时候,我们最容易想到的问题就是,一次发送多少bytes好? 当然,这个没有唯一答案,相对于不同的系统,不同的要求,其得到的答案是不一样的,我这里仅对 像ICQ一类的发送聊天消息 ...
