我想使用QLPreviewController来显示来自照片流的ALAssets QLPreviewController需要一个NSURL来显示项目
如果是文件URL (如/var/mobile/Applications/5374......9E0/Documents/image33.png ),则效果很好
我有一个ALAsset,但是使用[asset defaultRepresentation url]可以得到一个NSURL类型。
assets-library://asset/asset.JPG?id=00000000-0000-0000-0000-000000000075&ext=JPG
但这并不显示QLPreviewController只是一直显示正在加载??
有什么想法吗?提前感谢
发布于 2013-10-01 01:53:05
也许不是最快最有效的方法,但它解决了问题。请按照文档中的说明使用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;https://stackoverflow.com/questions/14791869
复制相似问题