开发者

show progress bar when uploadingan image to my server

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 pr开发者_如何学Pythongressing in console. but how i do that in nib file using 'progress bar'?


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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜