View Navigation with Segue

Last Updated: June 14, 2021

You can use the Segue to move from one scene to another scene

You can follow the following steps to load the screen 2 when you tough on the button Go to 2

Open the Document outline window and right click on the Second View Controller to open the popup window

Once you open the popup you can see the modal option under Presenting Segue. Hold the control key and drag the line to First View Controller as shown in the following images

Now you can name the segue

You can see the segue appearing under the First View Controller

When you select the segue you can see the identifier under the Attribute Inspector panel at the right side. You can name it as “segueonetotwo”

Next you create a outlet for the button “Go To 2” and put the following code

 @IBAction func actionShow(_ sender: Any) {
        self.performSegue(withIdentifier: "Segueonetotwo", sender:self)

Now you can load the Second View Controller