I have upload a file through my server and its working fine, but i want to show a progressview for upload status, How to do this, Please help me
Thanks in Advance
I tried this:
[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"file\"; filename=\"%@\"\r\n",file] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:Filedata];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:body];
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:request delegate:self];
if (theConnection)
mutaebleData = [[NSMutableData data] retain];
else
NSLog(@"No Connection");
Using this delegate to Upload data status, but it wont help
- (void)request:(NSURLConnection *)request
didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
{
NSLog(@"%d bytes out of %d sent.", totalBytesWritten, totalBytesExpectedToWrite);
}
Please have a look at this thread,It will help you:
How to track the progress of a download using ASIHTTPRequest (ASYNC)
This is the Best Custom controller for you.
It Custom UIActivityIndicator
that you can found from this link
https://github.com/jdg/MBProgressHUD
These is not apple specific controls. This MBProgressHUD controls consist of Three controls that describe in below.
UIImageView
with the image. UIActivityIndicatory
UILabel
with whatever message you want to display. MBProgressHUD
is an iOS drop-in class that displays a translucent HUD with an indicator and/or labels while work is being done in a background thread. The HUD is meant as a replacement for the undocumented, private UIKit UIProgressHUD with some additional features.......
For mor information go to above Link
The simplest you can alert a UIProgressView and int the delegate you can set the value of progress for example:
- (void)request:(NSURLConnection *)request
didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
{
NSLog(@"%d bytes out of %d sent.", totalBytesWritten, totalBytesExpectedToWrite);
UIProgressView *progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault];
[self.view addSubview:progressView];
progressView.progress = (double) bytesWritten / totalBytesWritten;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.