在ios上传数据的进度视图

时间:2015-12-24 11:14:08

标签: ios uiprogressview

我正在尝试使用ios应用程序中的POST方法上传数据。我想在上传数据时显示进度条指示器。我在另一个视图控制器和另一个类中的NSURLConnection委托方法中有进度条。我试过如下。

 -(void)updateProgressBar:(float)progressBarValue {

      NSLog(@"What is the progress bar indicator %f",progressBarValue);
      [self     performSelectorOnMainThread:@selector(updateProgressOnMainThread) withObject:nil waitUntilDone:NO];
progressBarValueForMinThread = &progressBarValue;

  }

 - (void)updateProgressOnMainThread {

       progressBar.progress = *(progressBarValueForMinThread);

  }

包含NSURLConnection方法的类

  - (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite{
       NSLog(@"bytesWritten %d",bytesWritten);
       NSLog(@"totalBytesWritten %d",totalBytesWritten);
       NSLog(@"totalBytesExpectedToWrite %d",totalBytesExpectedToWrite);
       progressedIndicator = ((float)totalBytesWritten / totalBytesExpectedToWrite);
       NSLog(@"DELEGATE PROGRESS INDICATOR %f",progressedIndicator);
       [objUpdatesController updateProgressBar:progressedIndicator];
}

" objUpdatesController"是包含进度条的类的对象。 任何帮助表示赞赏。

0 个答案:

没有答案