Consider a view with a button. We can drag a connection from this button to some other view controller, create a segue in IB and we are happy. What if I need a segue that is performed upon some event, say, network progress, and that is unrelated to any user actions? For now I'm placing a button, drag a segue from this button, hide the button, assign an identifier to a segue and somewhere in the code i perform this segue. However, I think that placing a dummy button is not a right way. Possibly I'm missing something using storyboards, could you please help me to understand this?
The segue needs to connect from the view controller itself so nothing else triggers it. To create a segue from the controller Control-drag from the View Controller icon to the Exit icon. Give this new segue the identifier unwind to reference it from the code.
Assigning an identifier for the segue:Select the segue, from the attribute inspector you'll see "Identifier" text field, that's it! make sure to insert the exact same name that used in performSegueWithIdentifier .
To create a segue between view controllers in the same storyboard file, Control-click an appropriate element in the first view controller and drag to the target view controller. The starting point of a segue must be a view or object with a defined action, such as a control, bar button item, or gesture recognizer.
Create your segue by ctrl dragging from your view controller to your next view. Then to call your segue, call:
[self performSegueWithIdentifier: @"SegueToScene1" sender: self];
Make sure you give your segue a name in the storyboard.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With