iPhone 的下载进度怎么弄?

qq313439161 2010-09-05 04:16:35
iPhone 的下载进度怎么弄?怎么得到下载请求的下载进度
...全文
836 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq313439161 2010-09-17
  • 打赏
  • 举报
回复
那个进度的显示, 可以根据关注UIProgressView 的 progress 值 进行改变, 也可以由时间来控制,

在指定的时间内进行进度的更新。。。。
fanxiaoduo 2010-09-15
  • 打赏
  • 举报
回复
iphone 父窗口与子窗口间的变量传递 各位有没有更好办法,请指教.


请到我的博客

http://blog.csdn.net/fanxiaoduo
qq313439161 2010-09-12
  • 打赏
  • 举报
回复
//可以通过设置代理来自动更改进度条的运动
[downloadRequest setDownloadProgressDelegate: progressView];

只要下载的进度改变 进度条(progressView)就可以自动改变
我的问题是如何在现实?%的时候可以自动更新显示 而不是手动的一直重复调用函数 重复调用函数会影响其他线程的运行。。。。。。。

不知道上述方法可不可以实现啊???

学习中。。。。。。。。。
陌尘笑 2010-09-09
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 cloudhsu 的回复:]

引用 5 楼 benyoulai5 的回复:
陈烨哥已经可以霸版了

左呆出现了...
[/Quote]
Zhangzm2005 2010-09-09
  • 打赏
  • 举报
回复
学吸了
ocwind 2010-09-08
  • 打赏
  • 举报
回复

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
//得到要下载文件的文件大小、文件名称
long length=[response expectedContentLength];
self.Myfilenmame=[response suggestedFilename];
self.Myfilelength=length;
//将文件名显示
self.label.text=Myfilenmame;
long firstleng = self.Myfilelength/3;
for (int i=0; i<2; i++) {
[self.r release];
self.r = [[NSMutableURLRequest alloc] initWithURL: url];

NSString *range = [[NSString alloc] initWithFormat:@"bytes=%d-%d", i*firstleng, (i+1)*firstleng];
[self.r setValue:range forHTTPHeaderField:@"Range"];
[range release];

NSString *tempname = [[NSString alloc] initWithFormat:@"%@%d.tmp", self.Myfilenmame, i];
TheardDown *threadload = [[TheardDown alloc] init];
[threadload init_all:tempname controllers:self mylength:firstleng myrequest:self.r];
[theards addObject:threadload];
[threadload release];
[tempname release];
}

self.r = [[NSMutableURLRequest alloc] initWithURL: url];

NSString *range = [[NSString alloc] initWithFormat:@"bytes=%d-", 2*firstleng];
[self.r setValue:range forHTTPHeaderField:@"Range"];
[range release];

TheardDown *threadload = [[TheardDown alloc] init];
NSString *tempname = [[NSString alloc] initWithFormat:@"%@%d.tmp", self.Myfilenmame, 2];
[threadload init_all:tempname controllers:self mylength:(self.Myfilelength - 2*firstleng) myrequest:self.r];
[theards addObject:threadload];
[threadload release];
[tempname release];
//设置几根线程在下载
self.count = 3;
[self.connection cancel];


}

ocwind 2010-09-08
  • 打赏
  • 举报
回复

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
//判断接受数据是否正确
NSHTTPURLResponse *res=(NSHTTPURLResponse *)response;
ringht = [res statusCode];
//if (ringht == 206) {
// //如果正确打开输出流
//
// NSString *openfile = [[NSString alloc] initWithFormat:@"%@%d.am", controller.Myfilenmame, controller.count];
// self.filestream=[NSOutputStream outputStreamToFileAtPath:[self FilePathByName:openfile] append:YES];
// [self.filestream open];
// }
}

//接收数据后回调
- (void)connection:(NSURLConnection *)connection
didReceiveData:(NSData *)data {
if (ringht == 206) {
NSString *openfile = [[NSString alloc] initWithFormat:@"%@%d.tmp", controller.Myfilenmame, controller.count];
self.filestream=[NSOutputStream outputStreamToFileAtPath:[self FilePathByName:openfile] append:YES];
[self.filestream open];

if (controller.Sueper) {
[self.filestream close];
[self.connection cancel];
}
else {
//将数据追加方式写出
[self.filestream write:[data bytes] maxLength:[data length]];
//修改进度条
self.Acturelength += [data length];
[_mydownCondition lock];
controller.Acturelength=controller.Acturelength+[data length];
controller.progress.progress= (controller.Acturelength*1.0)/controller.Myfilelength;
[_mydownCondition unlock];
}
}
}
ocwind 2010-09-08
  • 打赏
  • 举报
回复
在响应里面得到文件的总大小,然后根据每次下载下来的data的大小与总大小的比例,设置进度条
Steven_0610 2010-09-08
  • 打赏
  • 举报
回复
学习'''''''''''''
云瑀 2010-09-08
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 benyoulai5 的回复:]
陈烨哥已经可以霸版了
[/Quote]
左呆出现了...
陌尘笑 2010-09-08
  • 打赏
  • 举报
回复
陈烨哥已经可以霸版了
云瑀 2010-09-05
  • 打赏
  • 举报
回复
不知道....

29,027

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧