1

I am using NSTimer to call a device to take photos every 24.5 second.

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
dispatch_async( dispatch_get_main_queue(), ^{
    _photoTimer = [NSTimer scheduledTimerWithTimeInterval:24.5 target:self selector:@selector(takePhotos) userInfo:nil repeats:YES];     
});});

And at the 11th times, I switch to the main queue and call NSTimer stops, but it won't push to the next page.

-(void)takePhotos{
  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
   //taking photos....
  currenPageNumber +=1;

dispatch_async( dispatch_get_main_queue(), ^{
     //showing photos
 });
dispatch_async( dispatch_get_main_queue(), ^{
    if (currentCount == 11){
         [_photoTimer invalidate];
         _photoTimer = nil;
         UploadVC * uploadVC = [self.storyboard instantiateViewControllerWithIdentifier:@"UploadVC"];
         [self.navigationController presentViewController:uploadVC animated:YES completion:nil];
    }     
   });
   });
 }
dandan78
  • 13,328
  • 13
  • 64
  • 78
Satty
  • 157
  • 1
  • 1
  • 6

0 Answers0