0

テーブル ビューがスムーズに動作しないのはなぜですか? SDWebImageURLから画像を設定するために使用します。テーブル ビューの各行に 3 つの画像を描画しようとしています。

arrListが小さいときは問題なく動作しますが、 を大きくarrListすると、ますます遅くなります (テーブル ビューをスクロールすると、少し振動するように見えます)。

これは私のコードです:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"CustomCell";
    CustomCellTable *cell = (CustomCellTable*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        NSArray * nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCellTable" owner:self options:nil];
        cell = [nib objectAtIndex:0];
    }

    [cell setBackgroundColor:brgColor];
    // item 1
    if ((indexPath.row*3) > arrList.count-1) return cell;
    vod *Item = [arrList objectAtIndex:(indexPath.row*3)];
    [cell.image1 setHidden:NO];
    [cell.image1 setImageWithURL:[NSURL URLWithString:Item.imageURl] placeholderImage:[UIImage imageNamed:@"poster_default.png"]];
    [cell makeRating:[Item.rating floatValue] positionOf:14];
    // item 2
    if ((indexPath.row*3 +1) > arrList.count-1) return cell;
    Item = [arrList objectAtIndex:(indexPath.row*3+1)];
    [cell.image2 setHidden:NO];
    [cell.image2 setImageWithURL:[NSURL URLWithString:Item.imageURl] placeholderImage:[UIImage imageNamed:@"poster_default.png"]];
    [cell makeRating:[Item.rating floatValue] positionOf:118];
    // item 3
    if ((indexPath.row*3 +2) > arrList.count-1) return cell;
    Item = [arrList objectAtIndex:(indexPath.row*3+2)];
    [cell.image3 setHidden:NO];
    [cell.image3 setImageWithURL:[NSURL URLWithString:Item.imageURl] placeholderImage:[UIImage imageNamed:@"poster_default.png"]];
    [cell makeRating:[Item.rating floatValue] positionOf:225];

    return cell;
}
4

1 に答える 1