views:

653

answers:

1

Hi, my app upload an image to my server. i want to show this event by a progress bar.

  • (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite

  • (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response

  • (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data

  • (void)connectionDidFinishLoading:(NSURLConnection *)connection

i use this above methods to see the prgressing in console. but how i do that in nib file using 'progress bar'?

+3  A: 

If you use a UIProgressView you can set the progress in the connection:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite: method like this:

float progress = [[NSNumber numberWithInteger:totalBytesWritten] floatValue];
float total = [[NSNumber numberWithInteger: totalBytesExpectedToWrite] floatValue];
progressView.progress = progress/total;
Justin Gallagher