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 に答える