将数据从 A 传递到 C
如:在A
中键入一些字符串,然后单击按钮到B
,然后单击按钮到C
。
在C
的标签中显示字符串
我发现一些像这样的传递数据
例如:
在一个
类中
let bController = segue.destinationVieController
bController.string = "xxx"
但这只是A到B
如何将数据从 A
传递到 C
?
现在,我使用NSNotificationCetner
来完成这项工作,但我想学习如何使用segue闭包
如果真的很简单,请告诉我关键字
因为我只是搜索 A
到 B
...
谢谢!
最佳答案
您正在使用 segue 从 A->B 传递字符串,因此您现在在 Controller B 中拥有该字符串。使用如下所示的 segue 从 B-> C 传递相同的字符串
let cController = segue.destinationVieController
cController.string = string
其中 string 是 Controller B 中的变量,您在从 A->B 进行连接时为其分配了值
关于Swift 如何使用 Segue 通过 View Controller 传递数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36860778/