2013-03-19 46 views
0

我有上傳文件通過我的服務器和它工作正常,但我想說明上傳狀態progressview,如何做到這一點,請大家幫我將文件上傳到服務器以在iPhone中顯示UIProgressView?

由於提前

我嘗試這樣做:

 [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"); 

使用該委託上傳數據的狀態,但它不會幫助

- (void)request:(NSURLConnection *)request 
didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite 
{ 
    NSLog(@"%d bytes out of %d sent.", totalBytesWritten, totalBytesExpectedToWrite); 
} 

回答

0

這是最好的自定義控制器您。

它自定義UIActivityIndicator你可以從這個鏈接

https://github.com/jdg/MBProgressHUD

發現這些並不是蘋果的具體控制。這個MBProgressHUD控件由三個控件組成,如下所述。

  • 背景UIImageView與圖像。
  • UIActivityIndicatory
  • UILabel無論您想要顯示的任何消息。

MBProgressHUD是在iOS下拉式類顯示一個半透明HUD具有指示器和/或標籤,而工作在後臺線程正在做。該HUD是指作爲更換爲無證,私人的UIKit UIProgressHUD有一些額外的功能.......
如需更多信息,請訪問上面的鏈接

+0

感謝您的幫助 – SampathKumar 2013-03-19 06:33:06

-1

最簡單的,你可以提醒UIProgressView和int的委託可以設置的進度的值,例如:

- (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; 
} 
+0

我已經試過這個,並設置了中斷點,但沒有打電話給 – SampathKumar 2013-03-19 07:13:26

+0

@Minu你確定你已經開始了這個請求嗎? – Siverchen 2013-03-19 07:42:36

+0

你已經試過這個來解決它 – SampathKumar 2013-03-20 05:55:58

相關問題