AFNetworking怎么设置上传进度条?

查了一圈,查到了setuploadprogress这个方法,但是不知道怎么用。
补一下代码吧
AFHTTPRequestOperationManager*manager=[AFHTTPRequestOperationManagermanager];
[managerPOST:urlStrparameters:nilconstructingBodyWithBlock:^(idformData){
[formDataappendPartWithFileData:imgDataname:@"pic"fileName:fileNamemimeType:@"image/jpeg"];
}success:^(AFHTTPRequestOperation*operation,idresponseObject){
NSLog(@"success:%@",responseObject);
NSIntegerresult=[[responseObjectobjectForKey:@"result"]integerValue];
if(result==1){
successBlock(responseObject);
}else{
UIAlertView*alertView=[[UIAlertViewalloc]initWithTitle:nilmessage:@"出错了"delegate:nilcancelButtonTitle:@"ok"otherButtonTitles:nil,nil];
[alertViewshow];
}
}failure:^(AFHTTPRequestOperation*operation,NSError*error){
UIAlertView*alertView=[[UIAlertViewalloc]initWithTitle:nilmessage:[errorlocalizedDescription]delegate:nilcancelButtonTitle:@"ok"otherButtonTitles:nil,nil];
[alertViewshow];
failureBlock(error);
}];
慕运维8079593
浏览 371回答 2
2回答

呼如林

-(void)setUploadProgressBlock:(void(^)(NSUIntegerbytesWritten,longlongtotalBytesWritten,longlongtotalBytesExpectedToWrite))block;在block里totalBytesWritten/totalBytesExpectedToWrite

芜湖不芜

AFHTTPRequestOperation*op=xxx;[self.uploadProgressViewsetProgressWithUploadProgressOfOperation:opanimated:YES];
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript