为了账号安全,请及时绑定邮箱和手机立即绑定

AFNetworking怎么设置上传进度条?

AFNetworking怎么设置上传进度条?

慕运维8079593 2019-04-21 20:38:57
查了一圈,查到了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);}];
查看完整描述

2 回答

?
呼如林

TA贡献1798条经验 获得超3个赞

-(void)setUploadProgressBlock:(void(^)(NSUIntegerbytesWritten,longlongtotalBytesWritten,longlongtotalBytesExpectedToWrite))block;
在block里totalBytesWritten/totalBytesExpectedToWrite
                            
查看完整回答
反对 回复 2019-04-21
?
芜湖不芜

TA贡献1796条经验 获得超7个赞

AFHTTPRequestOperation*op=xxx;
[self.uploadProgressViewsetProgressWithUploadProgressOfOperation:opanimated:YES];
                            
查看完整回答
反对 回复 2019-04-21
  • 2 回答
  • 0 关注
  • 370 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信