I’m currently building an iPhone app and I want to customize a segue based on the value of a variable.
For example, if the variable value is 3, I want to go to a certain view and if the variable value is 5, I would want to go to a different view.
Also, I’m using the same view controller files for all of my views. Any ideas?
Thanks in advance.
It is not clear what you want to do.
You might have a first view controller and then push a second on top of that (it can be of the same class). In that case, make sure your view controller is wrapped in a navigation controller, create a new view controller in storyboard and make it the same class and draw a segue to it. Name the segue and call it from your first view controller. In
prepareForSegueyou can customize your second view controller based on any variables.Or you just want to show a few views in the same view controller. In this case you do not need a navigation controller. You can make the views appear, or animate them manually to slide in or out.
Usually the first approach is better because it gives you a simple mechanism to dismiss the view controller (with the different view) again.
As for the customization it would be something like this: