title: Dismiss view controller while a presentation is in progress
body: <p>I have a storyboard in my app with a push segue between <code>A</code> and <code>B</code>: so, <code>A</code> <code>-&gt;</code> <code>B</code>.  Basically, <code>A</code> is the view where the user does the actual work. <code>B</code> just shows a custom loading view.  When they press a button in <code>A</code>, the loading view <code>B</code> gets pushed onto the stack indicating that a network operation is in progress.  The network operation can either fail or succeed.  Either way, as soon as I know the result of the network operation, I want to pop B off the stack.  B is pushed on the stack with a segue, and I'm popping it off the stack with <code>dismissViewControllerAnimated</code>.  </p>
  
  <p>The problem I'm running into is that the network operation result is sometimes almost instantaneous (especially with failure/no connectivity), so that animating the loading view <code>B</code> onto the stack hasn't completed yet when I already want to remove it again.  This results in the XCode logging something along the lines of:</p>
  
  <blockquote>
    <p>Warning: Attempt to dismiss from view controller
     while a presentation or dismiss is
    in progress!</p>
  </blockquote>
  
  <p>... and the view never seems to pop off the stack as a result.  Is there a way around this?  I've read some similar questions here on SO, but they seem mostly to deal with pushing or popping multiple consecutive views with little gap, rather than a push/pop combination.</p>