为什么我的表格视图不能正常工作?我用来SDWebImage
从 URL 设置图像。我正在尝试在表格视图的每一行中绘制 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;
}