title: Perform an action BEFORE application enters background
body: <p>I'd like to close a modal view controller if my application enters the background.  I assumed by putting the code in applicationDidEnterBackground it would do the trick, but unfortunately the command isn't applied to the screen until the next time the app enters the foreground.  For a split second you can see the original modal view controller, which then disappears.</p>
  
  <p>Is there any kind of method like applicationWillEnterBackground?  Or is there a way of updating the UI before the app goes into the background.</p>
  
  <p>At the moment I have this code:</p>
  
  <pre><code>- (void)applicationDidEnterBackground:(UIApplication *)application {   
  
      NSLog(@"Application entered background state.");
  
      [splitVO dismissViewControllerAnimated:true completion:nil];
  }
  </code></pre>