UIProgressView + AFNetworking不更新进度

时间:2014-06-16 08:10:02

标签: ios afnetworking-2 uiprogressview

我正在尝试使用AFNetworking UIKit中的UIProgressView + AFNetworking类别。 我有一个将照片上传到服务器的操作。多张照片一下子。但我的进度视图根本没有更新。

在我的UIProgressView中,我使用

[progressView setProgressWithUploadProgressOfOperation:operation animated:YES];

我的要求是:

    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];

        }];

1 个答案:

答案 0 :(得分:0)

试试这个:

[operation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead){
        double progress = (double)totalBytesRead / totalBytesExpectedToRead;
        NSLog(@"Progress: %.2f", progress);
        // ...
    }];

我有自己的进度条,因此我在setDownloadProgressBlock块中更改了它的值。