0

I am sending a string to a web server from my iphone application. I am using UIProgressView to show the progress of request. Following is my code:

  -(IBAction)sendToServer:(id)sender{

NSString *url = [RequestUtil getWebURL];
NSString *jsonString = [JSONUtil jsonRunData: self.runDetails];
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:url]]; 
[request setTimeOutSeconds:60];
[request setPostValue:jsonString forKey:@"jsondata"];
[request setUploadProgressDelegate:myProgressIndicator];
[request setDelegate:self]; 
[request startAsynchronous];
progressTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(increaseAmount) userInfo:nil repeats:YES];
 }

 - (void)requestFailed:(ASIHTTPRequest *)request{
   self.myProgressIndicator.hidden = TRUE;
 //    alert
 }

 - (void)requestFinished:(ASIHTTPRequest *)request { 
   myProgressIndicator.progress = 1.0;
    // alert
 }

 -(void) increaseAmount{
progressNumber = progressNumber+0.2;
if(progressNumber <= 0.9){
    myProgressIndicator.progress = progressNumber;
}else {
    [progressTimer invalidate];
    progressNumber = 0.0;
}
 }

when i press send to server button, sendToServer is called. and it shows UIProgressView. Problem is that when progress view is showed it fills its progress bar quickly and then start again and acts on timer. Why progress view fills progress bar before it starts acting on behalf of timer?

4

1 回答 1

1

我知道这是一个老问题,您可能已经继续前进,但我怀疑问题的根源在于进度属性默认为动画。在显示进度视图之前调用 [myProgressIndicator setProgress:0.0 animated:NO]。

于 2012-04-11T17:04:34.833 回答