gpt4 book ai didi

ios - ALAssetRepresentation 全屏图像

转载 作者:行者123 更新时间:2023-11-29 03:33:22 25 4
gpt4 key购买 nike

我有一个 ALAssetRepresentation 问题。有一个表格以高分辨率显示图库图像。 fullScreenImage 方法花费太多时间,并且表格运行缓慢。如何实现更快的加载?例如,图库图像加载立即发生在https://itunes.apple.com/us/app/print-studio-print-photos/id601882801?mt=8中。 ,他们怎么能这么做?

  ALAsset *result = photos[_index];

UIImageView *photoView = (UIImageView*)[contentView viewWithTag:PHOTO_VIEW];

dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);

dispatch_async(queue, ^{
ALAssetRepresentation *represintation = [result defaultRepresentation];
NSURL* aURL = represintation.url;

[library assetForURL:aURL resultBlock:^(ALAsset *asset){

UIImage *copyOfOriginalImage = [UIImage imageWithCGImage:[[asset defaultRepresentation] fullScreenImage] scale:0.3 orientation:UIImageOrientationUp];
copyOfOriginalImage = [copyOfOriginalImage imageByScalingAndCroppingForSize:CGSizeMake(600, 600)];

dispatch_async(dispatch_get_main_queue(), ^{
[photoView setImage:newImg];
[photoView setNeedsDisplay];
});


}
failureBlock:nil];
});

最佳答案

您可以在图像滚动到屏幕上之前预加载它们。您预加载的图像可以在后台线程上完成并保存到 NSCache 实例中。缓存将自动清除(如果您设置了 countLimit 或设备内存不足),因此当您预加载时,检查缓存中的项目并在需要时在后台线程上加载。

关于ios - ALAssetRepresentation 全屏图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19496559/

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