Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to perform a segue that is not related to user input in iOS 5?

Tags:

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?

like image 709
anticyclope Avatar asked Nov 01 '11 09:11

anticyclope


People also ask

How do I connect to segue on IOS?

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.

How do I get a segue identifier?

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 .

How do you add a segue?

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.


1 Answers

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.

like image 183
Darren Avatar answered Sep 20 '22 15:09

Darren