解除未触发的segue [英] Unwind segue not being triggered

查看:189
本文介绍了解除未触发的segue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个故事板,它有一个启动视图控制器,可以显示其他模态视图控制器。

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

假设视图控制器A是startingViewController,视图控制器B是模态显示的视图控制器。

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

如何我可以从ViewController A(不仅仅是ViewController B上的按钮)触发从B回到A的展开segue吗?

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

该按钮用于执行展开segue ,但是当我尝试以编程方式执行它时

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

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

发生错误:

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

我不明白的是,当我按下模态视图控制器上的按钮时,展开segue工作正常,但当我尝试时找不到segue从另一个ViewContro触发它ller(标识符在故事板中是正确的)。

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).

有没有办法从我的startingViewController访问所有segue或者我的结构根本错误?

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

推荐答案

segue属于源 View Controller ,这就是你收到该错误消息的原因。 Segues旨在从源视图控制器中调用。

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.

如果要从A中解除viewControllerB,请不要使用segue,只需使用:

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

dismissViewControllerAnimated:completion:

这篇关于解除未触发的segue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆