CizooDev
CizooDev

Reputation: 81

How to transition to a view controller with gesture swift iOS

I have a problem with implementing a button which should redirect my current view to another view when tapping on it. I have a central view and I already implement the gestures on top, left and right to move to others views.

But on this central view I want to add a button that allows me to redirect towards my right screen without using gesture from right to left with my finger.

I added an IBOutlet action for this button, but I do not know what method to implement for switching back to my right screen (not the top or left screen).

If anyone can help me thank you very much!

Upvotes: 0

Views: 460

Answers (1)

Damiaan Dufaux
Damiaan Dufaux

Reputation: 4795

If you create a segue in Interface Builder and give it an identifier. You can then perform this segue (what you call "a transition") by calling

performSegue(withIdentifier: <String>, sender: self)

Of course you will need to replace <String> with your segue's identifier


  • One can create a segue by control dragging from one view controller to another view controller
  • One can give a segue an identifier by
    1. clicking on the just created segue (this is a line between the view cotrollers in the storyboard)
    2. opening the Attributes Inspector (press: altcmd4 or click on: View > Utilities > Show Attributes Inspector)
    3. filling in the textfield next to the label "Identifier"

Upvotes: 0

Related Questions