title: Custom transition for push animation with NavigationController on iOS 9
body: <p>I have a custom push transition between view controllers embedded in a <code>UINavigationController</code> which is working fine when built with iOS 7/8 but presents a wrong layout when built against iOS 9 SDK.</p>
  
  <pre><code>- (void)animateTransition:(id&lt;UIViewControllerContextTransitioning&gt;)transitionContext
  {
    UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
    UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
  
    [transitionContext.containerView addSubview:toViewController.view];
  
    ...
  </code></pre>
  
  <p>It then goes on and performs an animation. The issue is that the content of the <code>toViewController</code>, even though it is using the right top layout guide auto layout constraint, presents the content behind the navigation bar.</p>
  
  <p>Nevertheless, it works fine on iOS 8 and if we force a redraw (e.g., sending the app to the background and bring it back, present a modal on top and dismiss it, etc) will cause the whole auto layout system to redraw itself and <code>toViewController</code>'s view jumps to the right place (as being the top layout guide, x pixels from the navigation bar rather than x pixels from the top of the device's screen).</p>
  
  <p>Adding </p>
  
  <pre><code>[self.view setNeedsUpdateConstraints];
  [self.view layoutIfNeeded];
  </code></pre>
  
  <p>Works if put in <code>viewDidAppear:animated</code>, but does not work on <code>viewDidLoad</code> or <code>viewWillAppear:animated</code>. This is not a solution as users would see the view jumping when the redraw is happening at <code>viewDidAppear:animated</code></p>