override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "Choose Theme" {
if let themeName = (sender as? UIButton)?.currentTitle {
if let theme = themes[themeName] {
if let cvc = segue.destination as? ConcentrationViewController {
cvc.theme = theme
}
} else {
print("something went wrong")
}
} else {
print("couldnt get current title")
}
}
}这是密码。我在试着得到发件人目前的头衔。我尝试了调试,它打印“无法获得当前标题”,我得到的值是零。
我做错了什么?
提前感谢
发布于 2022-02-19 21:03:45
与其使用currentTitle,不如尝试使用titleLabel?.text。它似乎更可靠。我让你的程序工作(用Xcode测试)使用这个更改。
https://stackoverflow.com/questions/71113586
复制相似问题