0

我使用以下方法将图像保存到存储中:

UIImageWriteToSavedPhotosAlbum(image, self, 
                               @selector(image:didFinishSavingWithError:contextInfo:), nil);

现在,如何将该图像加载到图像视图中?

4

2 回答 2

2

图像视图有一个image属性。将图像分配给它。

编辑:如果要保存对相册中条目的持久引用,请不要使用该功能来保存它,writeImageToSavedPhotosAlbum:metadata:completionBlock:而是使用。完成块将被传递一个assetURL参数。

于 2012-08-01T15:21:41.877 回答
0

这是我现在使用的代码:

//Load the asset URL from my photo object
NSURL *asseturl = [NSURL URLWithString:photo.photoURL];

ALAssetsLibrary*  myasset = [[ALAssetsLibrary alloc] init];
//If the image was found
ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset)
{
    ALAssetRepresentation *rep = [myasset defaultRepresentation];
    //Get the full resolution image
    CGImageRef iref = [rep fullResolutionImage];
    if (iref) {
        //Get the orientation of the image
        ALAssetOrientation orientation = [[myasset valueForProperty:@"ALAssetPropertyOrientation"] intValue];
        //Set the image view image
        [self.BigImageView setImage:[UIImage imageWithCGImage:iref scale:1.0 orientation:orientation]];
    }
};
//If the image isn't available
ALAssetsLibraryAccessFailureBlock failureblock  = ^(NSError *myerror)
{
    NSLog(@"Can't get the image - %@",[myerror localizedDescription]);
    [self.BigImageView setImage:nil];
};

[myasset assetForURL:asseturl
    resultBlock:resultblock
    failureBlock:failureblock];
于 2012-08-15T15:51:19.320 回答