我使用afnetworking上传。当电话收到上传过程失败时。我该怎么办?
我的上传代码:
NSMutableDictionary *paraDict=[[NSMutableDictionary alloc]init];
[paraDict setObject:str_ImageData forKey:Content];
[paraDict setObject:str_ImageName forKey:Name];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.requestSerializer = [AFHTTPRequestSerializer serializer];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] requestWithMethod:@"POST" URLString:[NSString stringWithFormat:@"%@%@",API_URL,Upload_Image] parameters:paraDict error:nil];
NSLog(@"%@",str_ImageName);
NSLog(@"tamam");
AFHTTPRequestOperation *requestOperation = [manager HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseData) {
[requestOperation setUploadProgressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {
double percentDone = (double)totalBytesWritten / (double)totalBytesExpectedToWrite;
NSLog(@"progress updated(percentDone) : %f", percentDone);
progressView2.progress = percentDone;
}];
答案 0 :(得分:0)
请按照以下步骤操作
1-转到目标部分。
2-然后是功能。
3-然后背景模式。
4-在后台模式。
5-勾选你想要在后台执行的任何内容。
希望它能帮助你