2011-09-19 49 views

回答

0

你应该能够得到您的NSURLConnection的的委托预期的内容长度

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { 
    contentLength = [response expectedContentLength]; 
     downloadedContentLength = 0; 
... 
} 

然后跟踪的部分的长度,你已经在

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { 
    downloadedContentLength += [data length]; 
    int percentage = ((double)downloadedContentLength/contentLength)*100 
+0

'expectedContentLength'获得-1 –

相关问题