Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@chlebta 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
You can’t perform that action at this time.