Created
March 29, 2013 08:37
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This to old any update ?