0

I really love the graphical interface of the storyboard designer in Xcode, because all the segues are displayed with an arrow. enter image description here

But sometimes, when there is more complexity (e.g. variable to pass), I have to use a programatic way to switch to another ViewController.

let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
let nextViewController = storyBoard.instantiateViewController(withIdentifier: "HomeViewController") as! HomeViewController

// pass variable
nextViewController.email = self.textfieldEmail.text!

self.present(nextViewController, animated:true, completion:nil)

I dislike, that some of the segues in my App are displayed with an arrow in storyboard, while the more complex ones are not. Is there any way to show those more complex segues with an arrow in the Main.storyboard?

1 Answers1

1

There are two ways to achieve this:

  1. You can create segues in interface builder and pass data in prepareForSegue method
  2. When using code to switch controllers you can still create segue in your storyboard that you will not use - just for visualisation
Michał Kwiecień
  • 2,734
  • 1
  • 20
  • 23