title: How to navigate from one ViewController to another using a button. Swift 3 (No StoryBoard)
body: <p>I would like to navigate from my initial ViewController named "HomeController" to another view Controller named "CalendarController". I would like to do this by using a button called "CalendarButton". I would also like to do this with no reference to storyboard. Thanks</p>
  
  <p>error says: Pushing a navigation controller is not supported</p>
  
  <pre><code>import UIKit
  class HomeController: UICollectionViewController,UICollectionViewDelegateFlowLayout {
  
      private let cellId = "cellId"
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
      collectionView?.backgroundColor = UIColor.rgb(31, green: 194, blue: 31)
      collectionView!.isScrollEnabled = false
      collectionView? .register(MenuCell.self, forCellWithReuseIdentifier: cellId)
      }
  
      override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell{
         let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellId, for:indexPath) as! MenuCell
         cell.calendarButton.addTarget(self, action: #selector(calendar), for: .touchUpInside)
      return cell
      }
  
      func calendar() {
         let objVC: CalendarController! = CalendarController()
         let aObjNavi = UINavigationController(rootViewController: objVC!)
         self.navigationController?.pushViewController(aObjNavi, animated: true)
  
      }
  
      override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt;Int {
      return 1
  
     }
  
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -&gt; CGSize {
      return CGSize(width: view.frame.width, height: view.frame.height)
  
     }
  
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -&gt; CGFloat {
      return 0
     }
  
  }
  </code></pre>
  
  <p>// separate swift file</p>
  
  <pre><code>  class BaseCell: UICollectionViewCell{
    override init(frame: CGRect) {
      super.init(frame: frame)
      setupViews()
    }
    func setupViews() {
  
    }
    required init?(coder aDecoder: NSCoder) {
      fatalError("init(coder:) has not been implemented")
    }
  
  }
    class MenuCell: BaseCell{   
  
    lazy var calendarButton: UIButton = {
      let button = UIButton(type: .system)
      button.setTitle("Calender", for: .normal)
      button.setTitleColor(UIColor(red: 0, green: 0, blue: 0, alpha: 1), for: .normal)
      button.backgroundColor = .white
      button.titleLabel!.font = UIFont.systemFont(ofSize: 20)
      button.layer.cornerRadius = 15
      return button
  }()
  
    func calendar() {
      let newViewController = CalendarController()
      self.navigationController?.pushViewController(newViewController, animated: true)
  }
  </code></pre>