Skip to content

Instantly share code, notes, and snippets.

@duannguyenle
Last active February 8, 2018 08:12
Show Gist options
  • Save duannguyenle/c9f525a013a145b81918c843b512631d to your computer and use it in GitHub Desktop.
Save duannguyenle/c9f525a013a145b81918c843b512631d to your computer and use it in GitHub Desktop.
YangMingShan bug: Load Photo with network access allowed
// In YMSPhotoCell class
- (void)loadPhotoWithManager:(PHImageManager *)manager forAsset:(PHAsset *)asset targetSize:(CGSize)size
{
self.imageManager = manager;
PHImageRequestOptions *options = [[PHImageRequestOptions alloc] init];
options.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat;
options.networkAccessAllowed = YES;
options.resizeMode = PHImageRequestOptionsResizeModeExact;
options.synchronous = NO;
self.imageRequestID = [self.imageManager requestImageForAsset:asset
targetSize:size
contentMode:PHImageContentModeAspectFill
options:options
resultHandler:^(UIImage *result, NSDictionary *info) {
// Set the cell's thumbnail image if it's still showing the same asset.
if ([self.representedAssetIdentifier isEqualToString:asset.localIdentifier]) {
self.thumbnailImage = result;
}
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment