This article explains how to navigate to a specific view on a storyboard using code. Perform the following steps:
Step 1 – Give the view, to navigate to, a Storyboard ID
- Select the storyboard using the Project Navigator
- Within the storyboard, select the view you want to navigate to
- Go to the Identity Inspector
- Fill the Storyboard ID property with a unique view id (in the example below: “MyViewControllerStoryboardId”)
Step 2 – Write navigation code
private func navigateToMyViewController() { let myViewController = storyboard?.instantiateViewController(withIdentifier: "MyViewControllerStoryboardId") as UIViewController? navigationController?.show(myViewController!, sender: self) }