简体   繁体   English

UIProgressView + AFNetworking不更新进度

[英]UIProgressView+AFNetworking not updating progress

I am trying to use the category UIProgressView+AFNetworking from AFNetworking UIKit. 我正在尝试使用AFNetworking UIKit中的类别UIProgressView + AFNetworking。 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 在我的UIProgressView中,我使用

[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. 我有自己的进度条,因此我在setDownloadProgressBlock块中更改了它的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM