博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
测试SDWebImage淡入淡出效果在UITableView中的重用显示问题
阅读量:4315 次
发布时间:2019-06-06

本文共 3556 字,大约阅读时间需要 11 分钟。

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

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

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

源码:

ImageCell.h 与 ImageCell.m

////  ImageCell.h//  SDWebImageFade////  Created by YouXianMing on 14-10-5.//  Copyright (c) 2014年 YouXianMing. All rights reserved.//#import 
@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 ()
@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.bounds style: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:nil options:SDWebImageCacheMemoryOnly]; return cell;}- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 400;}@end

核心源码地方:

以下是测试的地方:

结论:

不会引起重用问题:)

 

转载于:https://www.cnblogs.com/YouXianMing/p/4006667.html

你可能感兴趣的文章
转 sql删除重复记录
查看>>
Yum数据库错误
查看>>
HDOJ树形DP专题之考研路茫茫——空调教室
查看>>
《结对-蓝牙考勤系统-测试过程》
查看>>
PAT 1034. Head of a Gang
查看>>
微信分享
查看>>
《数据结构》第1章:绪论
查看>>
基于域名的虚拟主机(最常用)
查看>>
第八讲 shiro 整合 ssm
查看>>
Lucene
查看>>
[LeetCode] 83. Remove Duplicates from Sorted List 移除有序链表中的重复项
查看>>
CNN反卷积理解
查看>>
chrome 中firstChild老是出错
查看>>
Java 7 新的 try-with-resources 语句,自动资源释放
查看>>
封装一个函数, 查看数字在数组中是否出现过, 如果出现过就返回数字在数组中的位置,没有出现过返回-1;...
查看>>
查看用户登录情况
查看>>
双栈排序-NOIP2008T4
查看>>
C#多线程及GDI(Day 23)
查看>>
static关键字
查看>>
Oracle the network adapter could not establish the connection
查看>>