title: Handling and running multiple ViewControllers in the same method
body: <p>I have a MainViewController which has a button init. On the button click a pictures starts animating, then I create a new instance of a different ViewController that runs a web request and extracts some info and push it in front. I wish the image to be animating while the middle view controller is running. Finally once the MiddleViewController is done, in the same button method I switch to a 3rd ViewController. As it is expected I get the following error:</p>
  
  <pre><code>    Warning: Attempt to present &lt;ThirdViewController: 0x962b470&gt; on &lt;MainViewController: 0x986c200&gt; while a presentation is in progress!
  Unbalanced calls to begin/end appearance transitions
  </code></pre>
  
  <p>How could I fix this? I prefer not to remove the middle ViewController and integrate its code in the MainViewController.</p>
  
  <pre><code>-(void)singleTapping:(UIGestureRecognizer *)recognizer
  {
  
      UIImage *rot1 = [UIImage imageNamed:@"pic1.png"];
      UIImage *rot2 = [UIImage imageNamed:@"pic2.png"];
      UIImage *rot3 = [UIImage imageNamed:@"pic3.png"];
      UIImage *rot4 = [UIImage imageNamed:@"pic4.png"];
  
      self.scanclickedimage.animationImages = [[NSArray alloc] initWithObjects:rot1, rot2, rot3, rot4, nil];
      self.scanclickedimage.animationDuration = 0.6f;
      self.scanclickedimage.animationRepeatCount = HUGE_VALF;
  
      [self.scanclickedimage startAnimating];
  
  
      if (nextString == NULL || [nextString isEqualToString:@""]) {
  
          NSLog(@"Initializing MiddleViewController");
          MiddleViewController * middleViewController = [[MiddleViewController alloc] init];
          middleViewController.delegate = self;
  
          [self presentViewController:middleViewController animated:YES completion:nil];
  
  
  
      } else {
          ProductWebRequest *request = [[ProductWebRequest alloc] init];
          [request sendWebRequest:nextString];
      }
  
  
  
  
  
  
      NSString * storyboardName = @"MainStoryboard";
      UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil];
      UIViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@"ThirdViewController"];
      vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
      [self presentViewController:vc animated:YES completion:nil];
  
  
  
  
  }
  </code></pre>