也许不是最快和最有效的方法,但它解决了问题。请使用 NSFilemanager 代替 NSTemporaryDirectory ,如文档中所示 :-) 确保链接到 ImageIO.framework
#import <ImageIO/ImageIO.h>
....
NSURL *outURLToUseWithQLPreviewController = nil;
ALAsset *myAsset = ... // received somehow
ALAssetRepresentation *represent = myAsset.defaultRepresentation;
CGImageRef representFullScreen = represent.fullScreenImage;
NSString *tempDir = NSTemporaryDirectory();
NSString *imagePath = [tempDir stringByAppendingPathComponent:represent.filename];
NSURL *tempURL = [NSURL fileURLWithPath:imagePath];
CGImageDestinationRef destination = CGImageDestinationCreateWithURL((__bridge CFURLRef)(tempURL), (__bridge CFStringRef)(represent.UTI), 1, NULL);
CGImageDestinationAddImage(destination, representFullScreen, nil);
if ( CGImageDestinationFinalize(destination) ) {
outURLToUseWithQLPreviewController = tempURL;
}
return outURLToUseWithQLPreviewController;