私のアプリでは、キャプチャした画像を 2 つの場所で使用しました。
view1
: 画像をキャプチャした後、すぐに imageView1 で使用/設定します。view2
: 2 番目のビューの imageView2で imageview1.image を再利用します。
最初の画像 view1 では、逆方向に撮影しても画像は適切に設定されています。
しかし、2番目の画像ではimageviw1.image
、逆方向に設定したものを再利用します。
画像をそのまま再利用するには?
私のアプリでは、キャプチャした画像を 2 つの場所で使用しました。
view1
: 画像をキャプチャした後、すぐに imageView1 で使用/設定します。view2
: 2 番目のビューの imageView2で imageview1.image を再利用します。最初の画像 view1 では、逆方向に撮影しても画像は適切に設定されています。
しかし、2番目の画像ではimageviw1.image
、逆方向に設定したものを再利用します。
画像をそのまま再利用するには?
使用する
[UIImage imageWithCGImage:iref scale:[rep scale] orientation:(UIImageOrientation)[rep orientation]];
例:
typedef void (^ALAssetsLibraryAssetForURLResultBlock)(ALAsset *asset);
typedef void (^ALAssetsLibraryAccessFailureBlock)(NSError *error);
ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset)
{
ALAssetRepresentation *rep = [myasset defaultRepresentation];
CGImageRef iref = [rep fullResolutionImage];
if (iref) {
UIImage *images = [UIImage imageWithCGImage:iref scale:[rep scale] orientation:(UIImageOrientation)[rep orientation]];
}
};
ALAssetsLibraryAccessFailureBlock failureblock = ^(NSError *myerror)
{
};
NSURL *asseturl = [NSURL URLWithString:@"fileURL"];
assetslibrary = [[ALAssetsLibrary alloc] init];
[assetslibrary assetForURL:asseturl
resultBlock:resultblock
failureBlock:failureblock];