title: How can I restart my block-based animation when the application comes to the foreground?
body: <p>I have the following block-based animation:</p>
  
  <pre><code>[UIView animateWithDuration:0.5f delay:0.0f 
                      options:UIViewAnimationOptionRepeat|UIViewAnimationOptionAutoreverse|UIViewAnimationOptionAllowUserInteraction|UIViewAnimationOptionCurveEaseInOut
                      animations:^{
                  [view.layer setTransform:CATransform3DMakeScale(1.3f, 1.3f, 1.0f)];
                  NSLog(@"animating");
                      }completion:^(BOOL finished){
                          NSLog(@"Completed");
                      }];
  </code></pre>
  
  <p>When the app returns from being in the background, the completion block is called, and my animations don't restart.  I've tried to use the following delegate method to restart the animations:</p>
  
  <pre><code>- (void)applicationWillEnterForeground:(UIApplication *)application
  {
      /*
       Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
       */
      [[self viewController] animate];
      ......
  }
  </code></pre>
  
  <p>but this hasn't worked to restore the animations.</p>
  
  <p>Similarly, I've tried the approaches laid out in the answers to these questions:</p>
  
  <ul>
  <li><p><a href="https://stackoverflow.com/questions/6042472/ios-restarting-animation-when-coming-out-of-the-background">iOS, Restarting animation when coming out of the background</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/7568567/restoring-animation-where-it-left-off-when-app-resumes-from-background%20%22">Restoring animation where it left off when app resumes from background</a></p></li>
  </ul>
  
  <p>but none of the suggestions there have worked for me.  Is there another way to resume block-based UIView animations when an application has returned from the background?</p>