title: Error: Could not cast value of type 'UINavigationController'
body: <p>I want to present a view controller in FavouriteButtonHandler on a button press.</p>
  
  <p>When I press the button, I get the following error:</p>
  
  <p><code>Could not cast value of type 'UINavigationController' (0x11177fed8)</code></p>
  
  <p>I searched for the cause of this error but do not know how to fix it.</p>
  
  <p>View controller code follows:</p>
  
  <pre><code>import UIKit
  
  @available(iOS 11.0, *)
  class FirstARViewController: UIViewController , UICollectionViewDelegate , UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
  
      @IBOutlet weak var collectionView: UICollectionView!
      var imagescv = ["ar1","ar2" ]
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          collectionView.delegate = self
          collectionView.dataSource = self
      }
  
      func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
          return imagescv.count
      }
  
      func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
  
          let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! cellimagesar
  
          cell.layer.cornerRadius = 5
  
          cell.layer.borderWidth = 1
  
          cell.myImages.image = UIImage(named: imagescv [indexPath.row])
          cell.myImages.contentMode = .scaleToFill
  
          cell.buttonMove.tag = indexPath.item
          cell.buttonMove.addTarget(self, action: #selector(self.FavouriteButtonHandler), for: .touchUpInside)
          //Declaring cell
  
          return cell
      }
      func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -&gt; CGSize {
          return CGSize(width: 171, height: 250)
      }
  
      @objc func FavouriteButtonHandler (sender: UIButton)
      {
          let VcToPresent = self.storyboard?.instantiateViewController(withIdentifier: "PDFViewController") as! PDFViewController
  
          switch sender.tag {
          case 0:
              //here you selected Button with tag 0
  
              //Time to update value of Global Struct
              ButtonSelected.Tag = 0
  
              //Time to present controller that will handle your pdf file and view it
  
          self.navigationController?.pushViewController(VcToPresent, animated: true)
  
              break
          case 1:
              //here you selected Button with tag 1
  
              //Time to update value of Global Struct
              ButtonSelected.Tag = 1
                      //Time to present controller that will handle your pdf file and view it
          self.navigationController?.pushViewController(VcToPresent, animated: true)
  
              break
          default:
              print("Error case")
          }
      }
  }
  </code></pre>
  
  <p>And I get the error in this line : </p>
  
  <pre><code> let VcToPresent = self.storyboard?.instantiateViewController(withIdentifier: "PDFViewController") as! PDFViewController
  </code></pre>