【发布时间】:2018-09-21 19:31:12
【问题描述】:
我查看了相关帖子,但我不明白为什么我的 ViewController 中没有调用它。
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
print("prepare in Start got triggered")
if segue.destination is RegistrationViewController {
let newVC = sender as? RegistrationViewController
newVC?.testString = "Mission accomplished, passed this data"
}
}
我通过按下按钮调用它
performSegue(withIdentifier: "RegistrationFromStart", sender: self)
testString 是 RegistrationViewController 中的一个属性 segue 发生了,没问题,但是属性永远不会改变,prepare 永远不会触发打印命令。
我在RegistrationViewController的viewDidLoad中打印testString
print("RegistrationViewController testString \(testString)")
提前感谢您的帮助。
【问题讨论】:
-
故事板中的segue连接是怎么做的?是来自 ViewController 还是来自按钮?
标签: ios swift uistoryboardsegue