我想使用QLPreviewController来显示Photo Stream中的ALAssets QLPreviewController需要NSURL才能显示项目
当它是文件URL时,这很有用 的/ var /移动/应用/ 5374 ...... 9E0 /文档/ image33.png
我有ALAsset
但是使用[[asset defaultRepresentation] url]给我一个NSURL类型
assets-library://asset/asset.JPG?id = 00000000-0000-0000-0000-000000000075& ext = JPG
但这不显示QLPreviewController只是一直显示加载??
有什么想法吗? 提前致谢
答案 0 :(得分:0)
也许不是最快最有效的方法,但它解决了这个问题。请使用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;