UITableViewCell gif animate very slow and almost stop #3549

40 views Asked by At

Every cell has a gif image. There are two gif images: A and B. If index%2==0 show A gif and index%2 == 0 show B gif.

I scroll (or quick scroll) the page in a few seconds

2.stop scroll, and wait a few second until page static

  1. The gif animation is very slow, almost stopped, there is a serious frame drop problem

image

UITableViewCell.m :

@implementation MyCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        SDAnimatedImageView *imgView = [[SDAnimatedImageView alloc] initWithFrame:CGRectMake(0, 0, 180, 180)];
        [self.contentView addSubview:imgView];
        self.imgView = imgView;
    }
    return self;
}

@end

ViewController.m

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 200;
}
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString* identifier = @"cell";
    MyCell* cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (!cell) {
        cell = [[MyCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    cell.textLabel.text = [NSString stringWithFormat:@"%ld", indexPath.row];
    if (indexPath.row%2 == 0) {
        [cell.imgView sd_setImageWithURL:[NSURL URLWithString:@"https://img.zcool.cn/community/016ccc5d7f8cb6a8012060be80ecdf.gif"]];
    } else if (indexPath.row%2 == 1) {
        [cell.imgView sd_setImageWithURL:[NSURL URLWithString:@"https://image.uisdc.com/wp-content/uploads/2018/12/0_AKELaQvbt2Ksbcpm.gif"]];
    }
    return cell;
}```



It takes me three days! I can't sovle it . Who can help me


  [1]: https://i.stack.imgur.com/1UoIE.png
0

There are 0 answers