I am trying to use the category UIProgressView+AFNetworking from AFNetworking UIKit. I have an operation that uploads photos to a server. Mulitple photos at once. But my progress view isn't updating at all.
In my UIProgressView I use
[progressView setProgressWithUploadProgressOfOperation:operation animated:YES];
And my request is:
AFHTTPRequestOperation *operation =
[manager POST:url parameters:params constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFileData:imageData name:@"imageFile" fileName:fileName mimeType:[NSString stringWithFormat:@"image/%@",fileMime]];
NSLog(@"Uploading...");
[SVProgressHUD showWithStatus:@"Uploading File..."];
} success:^(AFHTTPRequestOperation *operation, id responseObject) {
//Success
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
//Fail
[manager.operationQueue cancelAllOperations];
}];
Try this:
[operation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead){
double progress = (double)totalBytesRead / totalBytesExpectedToRead;
NSLog(@"Progress: %.2f", progress);
// ...
}];
I have my own progress bar, so I change its value in the setDownloadProgressBlock
block.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.