0
votes

I have a storyboard that has a starting view controller that presents other modal view controllers.

Say view controller A is the startingViewController, and view controller B is the modally presented view controller.

How can I trigger the unwind segue from B back to A, from ViewController A ( not just from a button located on ViewController B)?

The button works to perform the unwind segue , but when I try to perform it programmatically using

[self performSegueWithIdentifier:@"ReturnToStart" sender:self]

an error occurs:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<StartViewController: 0x1ed4b9b0>) has no segue with identifier 'ReturnToStart''

What I don't understand is that the unwind segue is working fine when I press a button on the modal view controller, but the segue just can't be found when I attempt to trigger it from another ViewController (The identifier is correct in storyboard).

Is there any way of accessing all of the segues from my startingViewController or is my structure fundamentally wrong?

1

1 Answers

2
votes

The segue "belongs" to the source View Controller, so that's why you get that error message. Segues are intended to be called from the source view controller.

If you want to dismiss viewControllerB from A, don't use a segue, just use:

dismissViewControllerAnimated:completion: