1

I am trying to save image to the photos album from my app using the following code:

 -(void)download:(UIButton *)downloadbtn{

    j=320*downloadbtn.tag;

    selectedIndex=downloadbtn.tag;

    NSData *data=[NSData dataWithContentsOfURL:[NSURL URLWithString:[live_god_img objectAtIndex:selectedIndex]]];

    UIImage*img=[UIImage imageWithData:data];

    UIImageWriteToSavedPhotosAlbum(img, self, nil, nil);

    UIAlertView*alert=[[UIAlertView alloc]initWithTitle:@"Success..!" message:@"Image Saved to the Photos" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];

    [alert show];

}

When the image is saved to the photos album, an alert view will be shown, but I would like to show a progress view while image is being saved to the album. I do not know how to use UIProgressView. How do I do it?

fpg1503
  • 7,492
  • 6
  • 29
  • 49
Ketan Jogal
  • 58
  • 10
  • 1
    You cannot unless your download operation is asynchronous. As your code is currently written (synchronously), there's no way to do it. – Cyrille Feb 23 '15 at 14:14

1 Answers1

0

Go through this tutorial first

You can try like this in your method.

- (IBAction)startProgress:(id)sender
    {
     progressValue = 0.0f;
     [self increaseProgressValue];
   }

-(void)increaseProgressValue
   {
   if(progressView.progress<1)
      {
    progressValue = progressValue+0.1;
    progressView.progress = progressValue;

   [self performSelector:@selector(increaseProgressValue) withObject:self afterDelay:0.2];
     }
  }
Pawan Rai
  • 3,434
  • 4
  • 32
  • 42
Teja Nandamuri
  • 11,045
  • 6
  • 57
  • 109
  • I agree with you @LittleBobbyTables . I was thinking in aspect of the person who asked the question but not the other stack flow users. I will provide the necessary info and will update the answer. :) – Teja Nandamuri Feb 23 '15 at 14:06