(博彩导航大全) AFNetworking怎么设置上传进度条?
在线博彩导航
在线博彩导航
当前位置 : 在线博彩导航 > 博彩导航大全

(博彩导航大全) AFNetworking怎么设置上传进度条?

查了一圈,查到了setuploadprogress 这个方法,但是不知道怎么用。
补一下代码吧

    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    [manager POST:urlStr parameters:nil constructingBodyWithBlock:^id<AFMultipartFormData> formData {
        [formData appendPartWithFileData:imgData name:@"pic" fileName:fileName mimeType:@"image/jpeg"];
    } success:^AFHTTPRequestOperation *operation, id responseObject {
        NSLog@"success:%@",responseObject;
        NSInteger result = [[responseObject objectForKey:@"result"] integerValue];
        if result == 1 {
            successBlockresponseObject;
        }else{
            UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:nil message:@"出错了" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
            [alertView show];
        }

    } failure:^AFHTTPRequestOperation *operation, NSError *error {
        UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:nil message:[error localizedDescription] delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
        [alertView show];
        failureBlockerror;
    }];
- voidsetUploadProgressBlock:void ^NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWriteblock;

在block里 totalBytesWritten / totalBytesExpectedToWrite

AFHTTPRequestOperation *op = xxx;
[self.uploadProgressView setProgressWithUploadProgressOfOperation:op animated:YES];

栏目列表

广告位

在线博彩导航