Ios UITableViewCell.imageView是否发出内存警告?

Ios UITableViewCell.imageView是否发出内存警告?,ios,objective-c,cocoa-touch,uitableview,Ios,Objective C,Cocoa Touch,Uitableview,我有一个表视图控制器,我在每个单元格的imageview中显示应用程序中录制的视频的缩略图。他们的身高是90.5,其实没什么特别的。然而,加载这个视图会增加40MB的内存,这太多了。我不知道为什么会发生这种情况,有人能提供一些见解吗 了解缩略图作为二进制数据存储在视频对象中可能很有用 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

我有一个表视图控制器,我在每个单元格的imageview中显示应用程序中录制的视频的缩略图。他们的身高是90.5,其实没什么特别的。然而,加载这个视图会增加40MB的内存,这太多了。我不知道为什么会发生这种情况,有人能提供一些见解吗

了解缩略图作为二进制数据存储在视频对象中可能很有用

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Video Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    self.tableView.rowHeight = 90.5;
    cell.imageView.tag = indexPath.row;


    Video *video = [self.videoArray objectAtIndex:indexPath.row];

    cell.textLabel.text = [self.dateFormatter stringFromDate:video.createdAt];

    cell.detailTextLabel.text = video.video_description;

    cell.detailTextLabel.text = @"Tap on the thumbnail to add video information!";

    cell.imageView.image = [UIImage imageWithData:video.thumbnail];

    UIView *highlighted = [[UIView alloc]initWithFrame:cell.bounds];

    [highlighted setBackgroundColor:[UIColor colorWithRed:0 green:122.0 / 255.0 blue:1.0 alpha:1.0]];

    cell.selectedBackgroundView = highlighted;
    cell.textLabel.highlightedTextColor = [UIColor whiteColor];
    cell.detailTextLabel.highlightedTextColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.70];

    return cell;
}
以下是我获取缩略图的方式:

- (UIImage *)generateThumbnailAtURL:(NSURL *)URL {

    AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:URL options:nil];
    AVAssetImageGenerator *generate = [[AVAssetImageGenerator alloc] initWithAsset:asset];
    //generate.appliesPreferredTrackTransform = YES;
    NSError *err = nil;
    double halfTime = ((CMTimeGetSeconds(asset.duration)) / 2);
    CMTime time = CMTimeMake(halfTime, 1);
    CGImageRef imgRef = [generate copyCGImageAtTime:time actualTime:nil error:&err];
    UIImage *thumbnail = [[UIImage alloc] initWithCGImage:imgRef];
    CGImageRelease(imgRef);

    [thumbnail imageByScalingToSize:CGSizeMake(130,90) contentMode:UIViewContentModeScaleAspectFill];

    return [UIImage imageWithData:UIImageJPEGRepresentation(thumbnail, 0.1)];
}

如果这是导致内存警告的线路:

cell.imageView.image = [UIImage imageWithData:video.thumbnail];

你只需要有较低的分辨率,这是一个细胞图像,高分辨率会像猎枪一样在内存中打洞。

Hmmm。这是一个高清视频的快照,但缩小到130x90,然后JPGRE显示为0.1,所以它不应该太大。你是对的。我忘了将130x90实际指定为新缩略图。哎呀。谢谢,这和猎枪很相似。