在iPad air上开发一个APP时,使用了AFNetworking进行下载zip包,在公司网络的情况下测试的时候是可以检测到下载进度的,但是拿到现场使用的时候,却没有下载进度,后来在用手机热点测试的时候,也是没有下载进度,实在是郁闷。百度、Google都搜索了,都没有发现类似的情况,再次请教一下各位大神,这到底是怎么一回事啊?`- (void)downLoadResource:(NSString )resourceURL model:(CarListCellModel )model{
[Tools showDial:self.controller.view];
self.cellModel = model;
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:resourceURL]];
NSURLSessionDownloadTask *task = [manager downloadTaskWithRequest:request
progress:^(NSProgress * _Nonnull downloadProgress) {
float percent = downloadProgress.completedUnitCount / (downloadProgress.totalUnitCount * 1.0);
_progressBlock(percent);
}
destination:^NSURL * _Nonnull(NSURL * _Nonnull targetPath, NSURLResponse * _Nonnull response) {
NSFileManager *fileManeger = [NSFileManager defaultManager];
BOOL isDirectory = YES;
if (![fileManeger fileExistsAtPath:UPDATE_RESOURCE_PATH isDirectory:&isDirectory]) {
[fileManeger createDirectoryAtPath:UPDATE_RESOURCE_PATH
withIntermediateDirectories:YES
attributes:nil
error:nil];
}
NSLog(@"%@",UPDATE_RESOURCE_PATH);
return [NSURL fileURLWithPath:[UPDATE_RESOURCE_PATH stringByAppendingPathComponent:[NSString stringWithFormat:@"/%@.zip",model.seriesID]]];
}
completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) {
if (error) {
[Tools showAlertMessage:@"下载失败"];
NSLog(@"%@",error);
}else{
[Tools showAlertMessage:@"下载成功"];
NSLog(@"%@", filePath);
[self unzipFile:model];
}
[Tools hideDial:self.controller.view];
}];
[task resume];
}`