Reputation: 683
How to show a progressbar during image downloading?
My code here:
[picView setImageWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:picURL]] placeholderImage:[UIImage imageNamed:@"placeholder.png"] success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
NSLog(@"success");
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
NSLog(@"fail");
}
];
Thank you in advance.
Upvotes: 3
Views: 2512
Reputation: 282
Take a look at this cocoa pod: https://github.com/xmartlabs/XLRemoteImageView . It allow you to show a progress indicator and also be updated about UIImage download progress. It uses objective-c internals and AFNetworking UIImage category to achieve what you want. I hope it helps you.
Upvotes: 0
Reputation: 19544
A progress bar is probably not the correct UI for this. Instead, you should probably use an indeterminate progress indicator (spinning bars). To do this in AFNetworking, use setImageWithURLRequest:placeholderImage:success:failure:
, hiding the progress indicator in success and failure.
If you did want to track the progress of a request, you would have to use AFImageRequestOperation
, and do setDownloadProgressBlock:
.
Upvotes: 7