title: Handling In-Call Status Bar with Custom Modal Presentation
body: <h1>The Problem</h1>
  
  <p>I've noticed some strange behavior when presenting a <code>UINavigationController</code> (with a root view controller, already pushed, naturally) with <code>UIViewControllerAnimatedTransitioning</code> during a phone call.</p>
  
  <ul>
  <li>If the in-call status bar is enabled <em>after</em> the the navigation controller is presented, the navigation controller shifts its view down as expected. But when the call is ended, the controller does not shift its view back up, leaving a 20p gap under the status bar.</li>
  <li>If the in-call status bar is enabled <em>before</em> presenting the controller, the controller does not account for the status bar at all, leaving 4p of the 44p-high navigation bar peeking out from under the 40p status bar. When the call is ended, the controller shifts its view down to accommodate the normal 20p status bar.</li>
  </ul>
  
  <p>*note: this was tested on the simulator, due to the ease of enabling/disabling the in-call status bar, but testers have observed this phenomenon on actual phones.</p>
  
  <h1>My (Partial) Workaround</h1>
  
  <p>I hacked around the issue by adjusting the frame of the controller during presentation, if the status bar was an abnormal height:</p>
  
  <pre><code>@interface CustomAnimationController : NSObject &lt;UIViewControllerAnimatedTransitioning&gt;
  @end
  
  @implementation CustomAnimationController
  
  - (void)animateTransition:(id&lt;UIViewControllerContextTransitioning&gt;)transitionContext
  {
      UIViewController *toController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
      UIView *container = [transitionContext containerView];
  
      CGRect frame = [transitionContext finalFrameForViewController:toController];
      if (CGRectEqualToRect(frame, CGRectZero))
      {
          // In my experience, the final frame is always a zero rect, so this is always hit
          UIEdgeInsets insets = UIEdgeInsetsZero;
          // My "solution" was to inset the container frame by the difference between the 
          // actual status bar height and the normal status bar height
          insets.top = CGRectGetHeight([UIApplication sharedApplication].statusBarFrame) - 20;
          frame = UIEdgeInsetsInsetRect(container.bounds, insets);
      }
  
      toController.view.frame = frame;
      [container addSubview:toController.view];
  
      // Perform whiz-bang animation here
  }    
  
  @end
  </code></pre>
  
  <p>This solution ensures that the navigation bar is below the status bar, but the navigation controller still fails to shift itself back up when the call is ended. So the app is at least usable, but there is an ugly 20p gap above the navigation bar after a call ends.</p>
  
  <h1>Is There a Better Way?</h1>
  
  <p>Am I missing some critical step to ensure that the navigation controller accounts for the in-call status bar on its own? It works just fine when presented with the built-in modal presentation style.</p>
  
  <p>In my opinion this smacks of a UIKit bug — after all, the navigation controller seems to receive the <code>UIApplicationWillChangeStatusBarFrameNotification</code> (see second point of The Problem). If anyone else has encountered this problem and has found a better way, I would greatly appreciate a solution.</p>