Flatlyn
Flatlyn

Reputation: 2050

Using Segue Manually

I need to create two Segue's from the same button, and then I want to programatically choice which one to use based on device orientation. The problem I'm having is that you can only seem to create one segue from a button to another view so when I add the second one it just changes the first.

How do you add a segue that either isn't linked to a button etc so I can do programatically or how are you supposed to do this. I want to have two views that get dynamically picked based on orientation rather than moving the objects based via code when rotated as there is alot of objects and custom stuff that would make it much simplier just to have two views.

Upvotes: 8

Views: 10153

Answers (2)

Marty
Marty

Reputation: 6184

You'd have to trigger the segue manually. Hook up the button to a method, then make two segues, one from each view controller to the other in your storyboard, then give it an identifier in IB, then in your method you can call "performSegueWithIdentifier:".

Additional Info

To make a manual segue, control-click from the view controller object in IB to another view controller and the box will pop up as "Manual Segue". Just make sure it has an identifier.

Upvotes: 17

timquinn
timquinn

Reputation: 446

I would think you could have the button trigger an IBAction wherein you could make a choice based on orientation and then trigger the appropriate segue programmatically.

Upvotes: 2

Related Questions