测试SDWebImage淡入淡出效果在UITableView中的重用显示问题

本文主要是介绍测试SDWebImage淡入淡出效果在UITableView中的重用显示问题,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

测试SDWebImage淡入淡出效果在UITableView中的重用显示问题

050744531282390.gif

这个是在上一篇教程的基础上所添加的测试环节!

效果图(从效果图中看是没有任何重用问题的):

050752298168042.gif

源码:

ImageCell.h 与 ImageCell.m

//
//  ImageCell.h
//  SDWebImageFade
//
//  Created by YouXianMing on 14-10-5.
//  Copyright (c) 2014年 YouXianMing. All rights reserved.
//

#import <UIKit/UIKit.h>@interface ImageCell : UITableViewCell@property (nonatomic, strong) UIImageView *bigImageView;@end
//
//  ImageCell.m
//  SDWebImageFade
//
//  Created by YouXianMing on 14-10-5.
//  Copyright (c) 2014年 YouXianMing. All rights reserved.
//

#import "ImageCell.h"@implementation ImageCell- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];if (self) {_bigImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 250, 400)];[self addSubview:_bigImageView];}return self;
}- (void)setSelected:(BOOL)selected animated:(BOOL)animated {[super setSelected:selected animated:animated];// Configure the view for the selected state
}@end

使用源码:

//
//  ViewController.m
//  SDWebImageFade
//
//  Created by YouXianMing on 14-10-5.
//  Copyright (c) 2014年 YouXianMing. All rights reserved.
//

#import "ViewController.h"
#import "UIImageView+WebCache.h"
#import "ImageCell.h"@interface ViewController ()<UITableViewDataSource, UITableViewDelegate>@property (nonatomic, strong) UITableView  *tableView;
@property (nonatomic, strong) NSArray      *dataArray;@end@implementation ViewController- (void)viewDidLoad {[super viewDidLoad];NSLog(@"%@", NSHomeDirectory());_dataArray = @[@"http://fc04.deviantart.net/fs70/f/2014/277/d/d/swan_song_by_lilyas-d81jjz1.jpg",@"http://fc08.deviantart.net/fs71/f/2013/103/8/d/8ddafeb73b9e146eef84cc0d45b4fe32-d61mj0f.jpg",@"http://fc08.deviantart.net/fs70/f/2013/120/8/1/pulsatilla_vulgaris_600_by_lilyas-d63la7p.jpg",@"http://fc01.deviantart.net/fs71/f/2012/160/c/0/c0690c165b549cc08b006943fcbcb542-d52u5nk.jpg",@"http://fc03.deviantart.net/fs71/f/2012/199/5/9/5978d4f115b1a70ed0cf6da4dc0cd164-d57qdzg.jpg",@"http://fc05.deviantart.net/fs70/f/2013/292/c/e/evening_star_by_lilyas-d6r3698.png",@"http://fc08.deviantart.net/fs70/i/2014/112/6/b/late_night_rose_by_lilyas-d63iu9y.jpg"];_tableView = [[UITableView alloc] initWithFrame:self.view.boundsstyle:UITableViewStylePlain];_tableView.delegate   = self;_tableView.dataSource = self;[self.view addSubview:_tableView];
}- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{return [_dataArray count];
}- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{static NSString *flag = @"YouXianMing";ImageCell *cell = [tableView dequeueReusableCellWithIdentifier:flag];if (cell == nil) {cell = [[ImageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:flag];cell.selectionStyle = UITableViewCellSelectionStyleNone;}NSString *urlStr = _dataArray[indexPath.row];[cell.bigImageView setImageWithURL:[NSURL URLWithString:urlStr]placeholderImage:niloptions:SDWebImageCacheMemoryOnly];return cell;
}- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{return 400;
}@end

核心源码地方:

050811054567143.gif

以下是测试的地方:

050809145816303.png

结论:

不会引起重用问题:)

 

这篇关于测试SDWebImage淡入淡出效果在UITableView中的重用显示问题的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1076071

相关文章

Redis 热 key 和大 key 问题小结

《Redis热key和大key问题小结》:本文主要介绍Redis热key和大key问题小结,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录一、什么是 Redis 热 key?热 key(Hot Key)定义: 热 key 常见表现:热 key 的风险:二、

IntelliJ IDEA 中配置 Spring MVC 环境的详细步骤及问题解决

《IntelliJIDEA中配置SpringMVC环境的详细步骤及问题解决》:本文主要介绍IntelliJIDEA中配置SpringMVC环境的详细步骤及问题解决,本文分步骤结合实例给大... 目录步骤 1:创建 Maven Web 项目步骤 2:添加 Spring MVC 依赖1、保存后执行2、将新的依赖

Spring 中的循环引用问题解决方法

《Spring中的循环引用问题解决方法》:本文主要介绍Spring中的循环引用问题解决方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录什么是循环引用?循环依赖三级缓存解决循环依赖二级缓存三级缓存本章来聊聊Spring 中的循环引用问题该如何解决。这里聊

Spring Boot中JSON数值溢出问题从报错到优雅解决办法

《SpringBoot中JSON数值溢出问题从报错到优雅解决办法》:本文主要介绍SpringBoot中JSON数值溢出问题从报错到优雅的解决办法,通过修改字段类型为Long、添加全局异常处理和... 目录一、问题背景:为什么我的接口突然报错了?二、为什么会发生这个错误?1. Java 数据类型的“容量”限制

关于MongoDB图片URL存储异常问题以及解决

《关于MongoDB图片URL存储异常问题以及解决》:本文主要介绍关于MongoDB图片URL存储异常问题以及解决方案,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐... 目录MongoDB图片URL存储异常问题项目场景问题描述原因分析解决方案预防措施js总结MongoDB图

SpringBoot项目中报错The field screenShot exceeds its maximum permitted size of 1048576 bytes.的问题及解决

《SpringBoot项目中报错ThefieldscreenShotexceedsitsmaximumpermittedsizeof1048576bytes.的问题及解决》这篇文章... 目录项目场景问题描述原因分析解决方案总结项目场景javascript提示:项目相关背景:项目场景:基于Spring

解决Maven项目idea找不到本地仓库jar包问题以及使用mvn install:install-file

《解决Maven项目idea找不到本地仓库jar包问题以及使用mvninstall:install-file》:本文主要介绍解决Maven项目idea找不到本地仓库jar包问题以及使用mvnin... 目录Maven项目idea找不到本地仓库jar包以及使用mvn install:install-file基

usb接口驱动异常问题常用解决方案

《usb接口驱动异常问题常用解决方案》当遇到USB接口驱动异常时,可以通过多种方法来解决,其中主要就包括重装USB控制器、禁用USB选择性暂停设置、更新或安装新的主板驱动等... usb接口驱动异常怎么办,USB接口驱动异常是常见问题,通常由驱动损坏、系统更新冲突、硬件故障或电源管理设置导致。以下是常用解决

Mysql如何解决死锁问题

《Mysql如何解决死锁问题》:本文主要介绍Mysql如何解决死锁问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录【一】mysql中锁分类和加锁情况【1】按锁的粒度分类全局锁表级锁行级锁【2】按锁的模式分类【二】加锁方式的影响因素【三】Mysql的死锁情况【1

SpringBoot内嵌Tomcat临时目录问题及解决

《SpringBoot内嵌Tomcat临时目录问题及解决》:本文主要介绍SpringBoot内嵌Tomcat临时目录问题及解决,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,... 目录SprinjavascriptgBoot内嵌Tomcat临时目录问题1.背景2.方案3.代码中配置t