pushViewController Swift Autolayout

//call in ViewdidLoad or in Button as
button.addTarget(self, action: #selector(backButtonAction), for: .touchUpInside)
button.addTarget(self, action: #selector(nextButtonAction), for: .touchUpInside)


//Next button Action
@objc func nextButtonAction(){
        let vc2 = SecondViewController()
        self.navigationController?.pushViewController(vc2, animated: true)
    }
//back button action
@objc func backButtonAction(){
        self.navigationController?.popViewController(animated: true)
    }

//if you are not using Storyboard
//also Verify in SceneDelegate 
var window: UIWindow?//verify
    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        guard let windowScene = (scene as? UIWindowScene) else { return }
      
      
      let navController = UINavigationController(rootViewController: FirstViewController())
        navController.setNavigationBarHidden(true, animated: true)
        
        window = UIWindow(frame: windowScene.coordinateSpace.bounds)
        window?.makeKeyAndVisible()
        window?.windowScene = windowScene
        window?.rootViewController = navController
	}
Lucky Lapwing