PHImageManagerでUIImagesを取得するのに奇妙な問題があります。PHImageManagerがフォトライブラリからの編集のために誤って写真を取得しています
要求されたUIImageがiPhoneの写真アプリから編集されていない場合は、すべて正常に動作します。ユーザーはiPhoneの自己フォトエディタから写真を編集した場合(つまり、sは/彼は絵をトリミング)することを
[[PHImageManager defaultManager] requestImageForAsset:[assets objectAtIndex:0] targetSize:PHImageManagerMaximumSize contentMode:PHImageContentModeDefault options:requestOptions resultHandler:^void(UIImage *image, NSDictionary *info)
{
DebugLog(@"%ld", assets.count);
@autoreleasepool
{
if (image)
{
// Write image to system
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *fileName = [NSString stringWithFormat:@"%ld_%@.jpg", (long)assets.count, [NSDate date]];
NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:fileName];
[UIImageJPEGRepresentation(image, 0.5) writeToFile:filePath atomically:YES];
}
}];
しかし、場合
PHImageManagerはその写真を取得するために失敗しました。を編集せず、resultHandlerで提供辞書は、 "情報" と呼ばれる正常です:
{
PHImageFileOrientationKey = 0;
PHImageFileSandboxExtensionTokenKey = "5565e83d376d8c4e018b8ea41401e58e5aabbc18;00000000;00000000;000000000000001a;com.apple.app-sandbox.read;00000001;01000003;000000000039a762;/private/var/mobile/Media/DCIM/113APPLE/IMG_3433.PNG";
PHImageFileURLKey = "file:///var/mobile/Media/DCIM/113APPLE/IMG_3433.PNG";
PHImageFileUTIKey = "public.png";
PHImageResultDeliveredImageFormatKey = 9999;
PHImageResultIsDegradedKey = 0;
PHImageResultIsInCloudKey = 0;
PHImageResultIsPlaceholderKey = 0;
PHImageResultOptimizedForSharing = 0;
PHImageResultRequestIDKey = 55;
PHImageResultWantedImageFormatKey = 9999;
}
しかしフォトアプリケーションからを編集した後の辞書は次のようになります。
{
PHImageFileOrientationKey = 0;
PHImageResultDeliveredImageFormatKey = 4031;
PHImageResultIsDegradedKey = 1;
PHImageResultRequestIDKey = 56;
PHImageResultWantedImageFormatKey = 9998;
}
以前にこの問題に直面した人はいますか?
あなたの返信ありがとうございます。
注:PHImageRequestOptionsVersionとPHImageRequestOptionsDeliveryModeは異なるenumです。 – BangOperator