简体   繁体   中英

Unwind segue not being triggered

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?

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:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM