【发布时间】:2023-04-06 03:40:01
【问题描述】:
我正在尝试使用两个不同的按钮访问两个不同的 VC。有了'newGeneratedListBtn,我只想去vc1。使用“newEmptyList”按钮,我想使用一个可以工作的布尔值转到 vc3。但是,当我单击第一个按钮 'newGeneratedListBtn' 转到 vc1 时,出现错误:“无法将 'AppName.vc1' 类型的值转换为 'AppName.vc3'。
似乎当我单击按钮到 vc1 时,它会尝试发送与我想发送到 vc3 相同的值。我该如何解决这个问题?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
let value = true
//Button to VC1
@IBAction func newGeneratedListBtn(_ sender: UIButton) {
performSegue(withIdentifier: "unwindSegueToVC1", sender: self)
}
//Value to send to VC2
override func prepare (for segue: UIStoryboardSegue, sender: Any!) {
let vc = segue.destination as! ListView
vc.newEmptyListValue = value
}
//Button to VC2
@IBAction func newEmptyList(_ sender: UIButton) {
performSegue(withIdentifier: "valueSender2", sender: self)
}
}
【问题讨论】:
标签: swift button uiviewcontroller uistoryboardsegue