【发布时间】:2014-05-06 08:04:12
【问题描述】:
使用 AFNetworking 2.0 的方法 setImageWithUrl,我在位于 UITableViewCell 的 imageView 中设置了一个图像。当显示的图像首先下载然后设置时,它工作正常。但是,如果图像在设置时在本地可用(已被缓存),则在显示之前会有一个快速的白色闪烁。
你知道如何避免这种情况吗?
重现步骤:
- 设置图片(图片会被缓存)
- 关闭申请
- 开始申请
- 设置(现在缓存的)图像
图片设置代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
myCell *cell = (myCell *)[tableView dequeueReusableCellWithIdentifier:@"imageCell"];
[cell.myImageView setImageWithURLRequest:[NSURLRequest requestWithURL:myImageUrl] placeholderImage:nil success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
cell.myImageView.image = image;
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
NSLog(@"Failed");
}];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
【问题讨论】:
标签: ios image caching afnetworking afnetworking-2