測試SDWebImage淡入淡出效果在UITableView中的重用顯示問題

來源:互聯網
上載者:User

標籤:style   blog   http   color   io   os   使用   ar   for   

測試SDWebImage淡入淡出效果在UITableView中的重用顯示問題

這個是在上一篇教程的基礎上所添加的測試環節!

(從中看是沒有任何重用問題的):

源碼:

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.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

核心源碼地方:

以下是測試的地方:

結論:

不會引起重用問題:)

 

測試SDWebImage淡入淡出效果在UITableView中的重用顯示問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.