在iOS 7中使用资源URL获取图像(UIImage)

我在我的相册中有一些图像。 我已经检索了所有这些资产的URL。我想要使用资产url获得一个特定的图像…下面的代码给了我资产的URL ..

ALAssetRepresentation *defaultRepresentation = [asset defaultRepresentation]; NSString *uti = [defaultRepresentation UTI]; NSURL *URL = [[asset valueForProperty:ALAssetPropertyURLs] valueForKey:uti]; 

现在使用这个URL,我怎么能得到图像(UIImage)?

通过这个获取Url,

 NSURL *url= (NSURL*) [[asset valueForProperty:ALAssetPropertyURLs] valueForKey:[[[asset valueForProperty:ALAssetPropertyURLs] allKeys] objectAtIndex:0]]; 

并从像下面的url获取图像。

 ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset) { ALAssetRepresentation *rep = [myasset defaultRepresentation]; @autoreleasepool { CGImageRef iref = [rep fullScreenImage]; if (iref) { UIImage *image = [UIImage imageWithCGImage:iref]; self.loadedImage = image; dispatch_async(dispatch_get_main_queue(), ^{ //UIMethod trigger... }); iref = nil; } } }; ALAssetsLibraryAccessFailureBlock failureblock = ^(NSError *myerror) { NSLog(@"Can't get image - %@",[myerror localizedDescription]); }; ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init]; [assetslibrary assetForURL:yourUrl resultBlock:resultblock failureBlock:failureblock]; 
 UIImage *img = [UIImage imageWithCGImage:[[myAsset defaultRepresentation] fullResolutionImage] 

希望这可以帮助