gpt4 book ai didi

ios - 无法在另一个 View Controller 中显示缩略图

转载 作者:行者123 更新时间:2023-11-29 01:56:48 26 4
gpt4 key购买 nike

- (void)displayThumbnail
{
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:[self outputURL] options:nil];
AVAssetImageGenerator *gen = [[AVAssetImageGenerator alloc] initWithAsset:asset];
gen.appliesPreferredTrackTransform = YES;
CMTime time = CMTimeMakeWithSeconds(1, 30);
NSError *error = nil;
CMTime actualTime;
CGImageRef imageref = [gen copyCGImageAtTime:time actualTime:&actualTime error:&error];
UIImage *thumbnail = [[UIImage alloc] initWithCGImage:imageref];
CGImageRelease(imageref);

UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];

MainViewController *controller = [mainStoryboard instantiateViewControllerWithIdentifier:@"MainViewController"];

controller.imageView.image = thumbnail;
}

我试图在另一个 View Controller 中显示录制视频的缩略图,但没有显示任何内容。我错过了什么吗?

最佳答案

在MainViewController.h中获取UIImage类型的属性

@property(strong,nonatomic) UIImage* thumbnailImg;

在 MainViewController.m 中

self.imageView.image = self.thumbnailImg;

设置这个属性

[controller setThumbnailImg: thumbnail]

关于ios - 无法在另一个 View Controller 中显示缩略图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30750586/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com