查了一圈,查到了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
芜湖不芜
TA贡献1796条经验 获得超7个赞
AFHTTPRequestOperation*op=xxx;[self.uploadProgressViewsetProgressWithUploadProgressOfOperation:opanimated:YES];
添加回答
举报
0/150
提交
取消