2

I have a UIActivityIndicatorView middle on camera OverlayView.xib. I am taking multiple snap by calling [cameraPicker takePicture] repeatedly. I want to show the indicator when all snaps taking done by the bellow code:

- (void)didTakePicture:(UIImage *)picture {   //Called from picker didFinishPickingMediaWithInfo

   [self.capturedImages addObject:picture];
   snapsCount ++;
   if (snapsCount < noOfSnaps) {
      [cameraPicker takePicture];
   }else {
     overlayView.indicator.hidden = NO;  //Not showing indicator
     [overlayView.indicator startAnimating]; //Not working
   }
}

Can anyone tell me the reason why not showing. I can show the indicator before taking the last snap by the following condition, but why not at last.

if (snapsCount < noOfSnaps) {
    if (snapsCount+1 == noOfSnaps) {

       overlayView.indicator.hidden = NO;  //Show the indicator
       [overlayView.indicator startAnimating];   //Work nicely
       overlayView.userMessage.text = @"Processing";
    }
    [cameraPicker takePicture];
}

Is there anyone faced the problem and know the solution to show the indicator after all snap taking done.

Thanks in advance.

kallol
  • 319
  • 1
  • 13
  • 1
    The code executes at about 0.0001 seconds, so by you starting and stoping the activity indicator in between actually does nothing (to the naked eye) — the code executes too fast. – WrightsCS May 23 '12 at 05:09
  • do animating in new thread and stop until last snap not taken – Paresh Navadiya May 23 '12 at 05:15
  • @safecase I have edited the question please take a look.. – kallol May 23 '12 at 05:22
  • if (snapsCount < noOfSnaps) { if (snapsCount+1 == noOfSnaps) { [overlayView.indicator stopAnimating]; //Work nicely overlayView.indicator.hidden = YES; //Show the indicator //overlayView.userMessage.text = @"Processing"; } overlayView.indicator.hidden = NO; //Show the indicator [overlayView.indicator startAnimating]; //Work nicely overlayView.userMessage.text = @"Processing"; [cameraPicker takePicture]; } it works activity indicator not shown then use a method which animates activity ind in a new thread – Paresh Navadiya May 23 '12 at 05:44

1 Answers1

0
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{

if (snapsCount > noOfSnaps) {
overlayView.indicator.hidden = NO;  
[overlayView.indicator startAnimating];
}
[NSTimer scheduledTimerWithTimeInterval:0.3
                                 target:self 
                               selector:@selector(didTakePicture:) 
                               userInfo: [info objectForKey:UIImagePickerControllerOriginalImage] 
                                repeats:NO];
}
Warif Akhand Rishi
  • 23,920
  • 8
  • 80
  • 107