gpt4 book ai didi

ios - 准备 segue 函数不加载新值

转载 作者:行者123 更新时间:2023-11-28 14:14:30 31 4
gpt4 key购买 nike

自上次调用 segue 以来,我的 UIButton 类的 statValue 属性已更新,但 segue 仍发送旧的原始值。有没有办法刷新 prepare 函数(如下),以便它发送新值?

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "StatDetailSegue" {
if let destinationVC = segue.destination as? StatDetailViewController,
let index = (sender as? StatButton)?.buttonIndex,
let sendVal = (sender as? StatButton)?.buttonValue,
let sendUnit = (sender as? StatButton)?.buttonUnit,
let sendTitle = (sender as? StatButton)?.detailTitle {
destinationVC.statID = index
destinationVC.statValue = sendVal
destinationVC.statUnit = sendUnit
destinationVC.statTitle = sendTitle
print("Destination STATID: \(destinationVC.statID)")
print("Destination value: \(destinationVC.statValue)")
}
}
}

最佳答案

检查你的 StatButton 如果你在 Storyboard中使用你的按钮,那么你的按钮应该继承自 StatButton 而不是 UIButton 否则你的代码看起来不错.

关于ios - 准备 segue 函数不加载新值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52249726/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com