title: The navigation controller delegate method is not getting a call
body: <p>In the following code, I am trying to create a custom animator during navigation transition but the navigation controller delegate method is not getting a call. Please look at the below code and suggest me a solution.</p>
  
  <p>Please note that I have embedded the DemoTransitionAnimationViewController in a navigation controller. This VC has a button on its view. On click of this view I am pushing another view controller. But still the delegate method is not getting a call.</p>
  
  <p><strong>CustomAnimator.swift</strong></p>
  
  <pre><code>//
  //  CustomAnimator.swift
  //  LoginModule
  //
  //  Created by Shubham Ojha on 8/14/17.
  //  Copyright © 2017 BBI. All rights reserved.
  //
  
  class FadeInAnimator: NSObject,
  UIViewControllerAnimatedTransitioning {
      func transitionDuration(
          using transitionContext: UIViewControllerContextTransitioning?
          ) -&gt; TimeInterval {
          return 0.35
  
      }
      func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
          let containerView = transitionContext.containerView
          let fromVC = transitionContext.viewController(
              forKey: UITransitionContextViewControllerKey.from)
          let toVC = transitionContext.viewController(
              forKey: UITransitionContextViewControllerKey.to)
  
          containerView.addSubview(toVC!.view)
          toVC!.view.alpha = 0.0
  
          let duration = transitionDuration(using: transitionContext)
          UIView.animate(withDuration: duration, animations: {
              toVC!.view.alpha = 1.0
              toVC?.view.backgroundColor = UIColor.blue
          }, completion: { finished in
              let cancelled = transitionContext.transitionWasCancelled
              transitionContext.completeTransition(!cancelled)
          })
      }
  
  }
  
  class NavigationControllerDelegate: NSObject,
  UINavigationControllerDelegate {
  
      func navigationController(
          _ navigationController: UINavigationController,
          animationControllerFor operation:
          UINavigationControllerOperation,
          from fromVC: UIViewController,
          to toVC: UIViewController
          ) -&gt; UIViewControllerAnimatedTransitioning? {
  
          return FadeInAnimator()
  
      }
  }
  </code></pre>
  
  <p><strong>DemoTransitionAnimationViewController.swift</strong></p>
  
  <pre><code>//
  //  DemoTransitionAnimationViewController.swift
  //  LoginModule
  //
  //  Created by Shubham Ojha on 8/15/17.
  //  Copyright © 2017 BBI. All rights reserved.
  //
  
  import UIKit
  
  class DemoTransitionAnimationViewController: UIViewController {
  
      override func viewDidLoad() {
          super.viewDidLoad()
          print(self.navigationController ?? "Not exist")
  
          if self.navigationController != nil{
              self.navigationController?.delegate = NavigationControllerDelegate()
         // In the above statement if I am setting the delegate as self instead of 
        //NavigationControllerDelegate() and conforming the methods of navigation 
        //controller delegate protocol. It works perfectly.
          }
          else{
              print("navigation controller does not exist")
          }
  
      }
  
  }
  </code></pre>