Show ViewSontrollers without using buttons

Hi I have a settings ViewController that I want to show if the users want to add details. Therefore i have no need for a button and want to display the screen when a data set is nil.
I for the life of me cannot figure out how to do this…do you create a manual segue?

Oh dear, I had some temp code that caused a spanner in the works but just to make sure that this is the right way of doing it…

I created a manual segue gave it a name getSettingsSegue

and when the dataset is nil I call …self.performSegue(withIdentifier:“getSettingsSegue”, sender:nil)

Hi @equiavia,
Have you tried instantiating a viewController from a Storyboard and then presenting it or pushing it on the view hierarchy?

let sb = UIStoryboard(name:"Main", bundle: nil)
let theVC = sb.instantiateViewController(withIdentifier: "IDENTIFIER")

//Now present it
self.present(theVC, animated: true, completion: nil)

// or use the  pushViewController
//self.navigationController?.pushViewController(theVC, animated: true)

If you want to manage everything via segues only, then you can have a look at these tutorials on this site

Lastly, I was curious to understand how would you trigger the manual segue? Generally If I had a button, I would have an if condition to trigger a segue or not trigger a segue. Similarly, I could do the same with instantiated viewControllers.



This topic was automatically closed after 166 days. New replies are no longer allowed.