Skip to content

Instantly share code, notes, and snippets.

@martinpilch
Created March 29, 2013 08:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinpilch/5269512 to your computer and use it in GitHub Desktop.
Save martinpilch/5269512 to your computer and use it in GitHub Desktop.
Simple UIImageView category to get download progress by extenging UIImageView+AFNetworking.h category
//
// UIImageView+DownloadProgress.h
//
//
// Created by Martin Pilch on 3/29/13.
//
//
#import "UIImageView+AFNetworking.h"
@interface UIImageView (DownloadProgress)
- (void)setImageWithURLRequest:(NSURLRequest *)urlRequest placeholderImage:(UIImage *)placeholderImage
success:(void (^)(NSURLRequest *, NSHTTPURLResponse *, UIImage *))success
failure:(void (^)(NSURLRequest *, NSHTTPURLResponse *, NSError *))failure
downloadProgressBlock:(void (^)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))downloadProgressBlock;
@end
//
// UIImageView+DownloadProgress.m
//
//
// Created by Martin Pilch on 3/29/13.
//
//
#import "UIImageView+DownloadProgress.h"
@implementation UIImageView (DownloadProgress)
- (void)setImageWithURLRequest:(NSURLRequest *)urlRequest placeholderImage:(UIImage *)placeholderImage
success:(void (^)(NSURLRequest *, NSHTTPURLResponse *, UIImage *))success
failure:(void (^)(NSURLRequest *, NSHTTPURLResponse *, NSError *))failure
downloadProgressBlock:(void (^)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))downloadProgressBlock {
[self setImageWithURLRequest:urlRequest placeholderImage:placeholderImage success:success failure:failure];
if ( [self respondsToSelector:@selector(af_imageRequestOperation)] ) {
[[self performSelector:@selector(af_imageRequestOperation)] setDownloadProgressBlock:downloadProgressBlock];
}
}
@end
@chlebta
Copy link

chlebta commented Jun 24, 2015

This to old any update ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment