我正在尝试为iOS5之前的ALAsset
创建宽高比缩略图(直到ios5才会实现ALAssetDefaultRepresentation aspectRatioThumbnail
)。我有以下代码,它出于某种原因给我一个错误:
CGImageRef imref;
NSURL* url = [self.photoAsset.defaultRepresentation url];
NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:
(id)kCFBooleanTrue, kCGImageSourceShouldAllowFloat,
(id)kCFBooleanTrue, kCGImageSourceCreateThumbnailWithTransform,
(id)kCFBooleanTrue, kCGImageSourceCreateThumbnailFromImageAlways,
[NSNumber numberWithInteger:1024], kCGImageSourceThumbnailMaxPixelSize, nil];
CGImageSourceRef src = CGImageSourceCreateWithURL((CFURLRef)url, NULL);
imref = CGImageSourceCreateThumbnailAtIndex(src, 0, (CFDictionaryRef) dictionary);
具体来说,我得到了:
ImageIO: <ERROR> CGImageSourceCreateWithURL CFURLCreateDataAndPropertiesFromResource failed with error code -11.ImageIO: <ERROR> CGImageSourceCreateThumbnailAtIndex image source parameter is nil
任何人都知道发生了什么事?
答案 0 :(得分:1)
问题在于您要传递的url
来创建“src
”,
check wether url
有效且此网址上有一些图片。