我正在开发适用于iPad的iOS应用程序,我正在使用名为Grabkit的存储库,以获取来自Instagram和Flicker等不同服务的图像以及来自相机胶卷的图像。问题是,当用户从滚动中选择一张图片时我得到的URL和URL如下:assets-library://asset/asset.JPG?id = DCFB9E49-93AA-49E3-89C8-2EE64AE2C4C6& ext = JPG 我已经尝试了一些代码来从这种路径中获取图像,但没有人工作过,如下所示:
ALAssetsLibrary* library = [[ALAssetsLibrary alloc] init];
// Ask for the "Asset" for the URL. An asset is a representation of an image in the Photo application.
[library assetForURL:originalImage.URL
resultBlock:^(ALAsset *asset) {
// Here, we have the asset, let's retrieve the image from it
CGImageRef imgRef = [[asset defaultRepresentation] fullResolutionImage];
/* Instead of the full res image, you can ask for an image that fits the screen
CGImageRef imgRef = [[asset defaultRepresentation] fullScreenImage];
*/
// From the CGImage, let's build an UIImage
imatgetemporal = [UIImage imageWithCGImage:imgRef];
} failureBlock:^(NSError *error) {
// Something wrong happened.
}];
我的代码中的某些内容是错误的吗?我必须尝试其他代码吗?