【发布时间】:2012-10-08 04:36:14
【问题描述】:
我正在尝试刷新 UIProgressView 中的进度条,以获取 NSURLConnection 的上传请求。目标是在上传图片时刷新进度条。经过几次搜索,我设法使用我的连接委托的didSendBodyData 来检查进度:
- (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
{
if([self.delegate respondsToSelector:@selector(progressView)])
{
self.delegate.progressView.progress = (totalBytesWritten / totalBytesExpectedToWrite) * 100.0;
}
}
一切正常,但问题是这个方法只被调用一次......所以酒吧停留在 0% 片刻,然后立即进入 100% 没有中间。我尝试(在 iPhone 上使用 iOS6 开发者工具)将我的连接设置为慢速边缘连接,以判断是否只是我的上传速度太快,但不,上传需要一段时间为 0,然后立即转到 100% 并且该方法只被调用一次...
有什么想法吗?谢谢 !我不知道如何解决这个问题......
【问题讨论】:
标签: ios ios5 ios6 nsurlconnection nsurlconnectiondelegate