Commit 6b07cc52 authored by maji's avatar maji

fix 内存泄漏(当targetSize传值为PHImageManagerMaximumSize时,...

fix 内存泄漏(当targetSize传值为PHImageManagerMaximumSize时, requestImageForAsset方法调用会产生内存泄漏. 用"requestImageDataForAsset"方法替换)
parent ba97a4a2
...@@ -467,14 +467,14 @@ static dispatch_once_t onceToken; ...@@ -467,14 +467,14 @@ static dispatch_once_t onceToken;
[option setProgressHandler:progressHandler]; [option setProgressHandler:progressHandler];
} }
option.resizeMode = PHImageRequestOptionsResizeModeFast; option.resizeMode = PHImageRequestOptionsResizeModeFast;
return [[PHImageManager defaultManager] requestImageForAsset:asset targetSize:PHImageManagerMaximumSize contentMode:PHImageContentModeAspectFit options:option resultHandler:^(UIImage *result, NSDictionary *info) { return [[PHImageManager defaultManager] requestImageDataForAsset:asset options:option resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) {
BOOL cancelled = [[info objectForKey:PHImageCancelledKey] boolValue]; BOOL cancelled = [[info objectForKey:PHImageCancelledKey] boolValue];
if (!cancelled && result) { if (!cancelled && imageData) {
result = [self fixOrientation:result]; UIImage *result = [self fixOrientation:[UIImage imageWithData:imageData]];
BOOL isDegraded = [[info objectForKey:PHImageResultIsDegradedKey] boolValue]; BOOL isDegraded = [[info objectForKey:PHImageResultIsDegradedKey] boolValue];
if (completion) completion(result,info,isDegraded); if (completion) completion(result,info,isDegraded);
} }
}]; }];
} }
- (PHImageRequestID)getOriginalPhotoDataWithAsset:(PHAsset *)asset completion:(void (^)(NSData *data,NSDictionary *info,BOOL isDegraded))completion { - (PHImageRequestID)getOriginalPhotoDataWithAsset:(PHAsset *)asset completion:(void (^)(NSData *data,NSDictionary *info,BOOL isDegraded))completion {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment