guard let destinationVC = mainStoryboard.instantiateViewController(withIdentifier: "YourStoryBoardID") as? YourViewControllerClassName else {
return
}
as? YourViewControllerClassName
You need to pass the name of the View Controller not the Storyboard ID here.
UPDATE:
As your current view controller is not embedded in navigationController, navigationController?.pushViewController
this returns nil and the line is not executed. To execute this line, your view controller should have a navigation controller.
To embed your controller in navigation Controller : Follow point no:1 ,2 ,3 here
If you do not want to use navigationController, you can use presentViewController
instead.
guard let destinationVC = mainStoryboard.instantiateViewController(withIdentifier: "YourStoryBoardID") as? YourViewControllerClassName else {
return
}
self.present(destinationVC, animated: true, completion: nil)
Also learn about when to push and when to present a view controller