如何使用ASIHTTPRequest(ASYNC)跟踪下载进度
||
我目前在网站上使用异步调用我的API(我设置)。我正在将ASIHTTPRequest的setDownloadProgressDelegate与UIProgressView一起使用。但是我不知道如何调用选择器(updateProgress),该选择器会将CGFloat \'progress \'设置为progressView \的进度。我尝试了以下方法,但是两个进度均为零。请您告诉我如何进行这项工作?
(in some method)
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:[url stringByAppendingFormat:@\"confidential\"]]];
[request setDownloadProgressDelegate:progressView];
[NSTimer scheduledTimerWithTimeInterval:1.0f/60.0f target:self selector:@selector(updateProgress:) userInfo:nil repeats:YES];
[request setCompletionBlock:^{~100 lines of code}];
[request setFailedBlock:^{~2 lines of code :) }];
[request startAsynchronous];
- (void) updateProgress:(NSTimer *)timer {
if (progressView.progress < 1.0) {
currentProgress = progressView.progress;
NSLog(@\"currProg: %f --- progressViewProg: %f\", currentProgress, progressView.progress);
}
else {
[timer invalidate];
}
return;
}
没有找到相关结果
已邀请:
3 个回复
蹄寄噬非芹
它不会帮助您调用
,
会更改进度指示器本身。
凄嘛姥
。在此实现中,更新您的进度变量,然后调用
或在代码中,设置请求的下载进度委托:
然后将方法添加到您的类中:
弦砂牧扁