Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perform Segue Programmatically Without Button Connection?

I have two view controllers in my storyboard and I need to push from view 1 to view 2.

I need to do this without connecting a segue directly from a button in my storyboard, I need to do it programatically.

How can I?

Thanks.

like image 963
Josh Kahane Avatar asked Jul 25 '12 16:07

Josh Kahane


People also ask

How do you do segue programmatically?

First, select a segue in your storyboard, then go to the attributes inspector and give it a name such as “showDetail”. Technically the sender parameter is whatever triggered the segue, but you can put whatever you want in there.

How do you unwind segue programmatically?

Quoting text from Apple's Technical Note on Unwind Segue: To add an unwind segue that will only be triggered programmatically, control+drag from the scene's view controller icon to its exit icon, then select an unwind action for the new segue from the popup menu.


1 Answers

When you click the button call:

[self performSegueWithIdentifier:@"SegueIdentifier" sender:self]; 

You will need to create the segue in the storyboard but you can do it from view controller to view controller instead of button to viewcontroller.

like image 161
StuStirling Avatar answered Oct 08 '22 23:10

StuStirling