0

我已经使用自定义单元格从 tableView 中的文件夹加载了图像,该单元格在每行中有三个图像。即使我调整了图像大小,当向上或向下滚动时它也会变慢

-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"cell";

CustomCell *cell = (CustomCell *) [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

if (cell == nil) {
    [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
    cell = customCell;
}

if ([imageLists count] > indexPath.row*noOfImageInRow) {

    ImagesClass *Obj1 = [imageLists objectAtIndex:indexPath.row*noOfImageInRow];

    UIImage *image1 = [self getImageForImageId:Obj1.imageId FromPath:SAVEDIMAGE_DIR];
    Obj1.thumbImage = [self imageWithImage:image1 convertToSize:CGSizeMake(130, 130)];

    [cell setImage:1 :Obj1.thumbImage RowNo:indexPath.row*noOfImageInRow];
4

1 回答 1

0

表格视图中没有延迟加载

   [cell setImage:2 :Obj2.thumbImage RowNo:indexPath.row*noOfImageInRow+1];

这些功能需要更多时间来执行

UIImage *image1 = [self getImageForImageId:Obj1.imageId FromPath:SAVEDIMAGE_DIR];
Obj1.thumbImage = [self imageWithImage:image1 convertToSize:CGSizeMake(130, 130)];

请参阅 Apple 了解延迟加载图像概念。

我不会描述什么是延迟加载,希望这对你有用

于 2013-02-12T11:57:03.913 回答