Skip to content

Commit

Permalink
Fix SDWebImageManager method call
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardocallado committed May 25, 2017
1 parent e9fa1cf commit eaced5b
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions Classes/IDMPhoto.m
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,20 @@ - (void)loadUnderlyingImageAndNotify {
[self performSelectorInBackground:@selector(loadImageFromFileAsync) withObject:nil];
} else if (_photoURL) {
// Load async from web (using SDWebImageManager)
[[SDWebImageManager sharedManager] downloadImageWithURL:_photoURL options:SDWebImageRetryFailed|SDWebImageHandleCookies progress:^(NSInteger receivedSize, NSInteger expectedSize) {
CGFloat progress = ((CGFloat)receivedSize)/((CGFloat)expectedSize);

if (self.progressUpdateBlock) {
self.progressUpdateBlock(progress);
}
} completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
if (image) {
self.underlyingImage = image;
}

[self performSelectorOnMainThread:@selector(imageLoadingComplete) withObject:nil waitUntilDone:NO];
}];

[[SDWebImageManager sharedManager] loadImageWithURL:_photoURL options:SDWebImageRetryFailed progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {
CGFloat progress = ((CGFloat)receivedSize)/((CGFloat)expectedSize);

if (self.progressUpdateBlock) {
self.progressUpdateBlock(progress);
}
} completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) {
if (image) {
self.underlyingImage = image;
}

[self performSelectorOnMainThread:@selector(imageLoadingComplete) withObject:nil waitUntilDone:NO];
}];
} else {
// Failed - no source
self.underlyingImage = nil;
Expand Down

0 comments on commit eaced5b

Please sign in to comment.