gpt4 book ai didi

ios - 覆盖 prepareForSegue 不起作用

转载 作者:搜寻专家 更新时间:2023-11-01 07:19:59 24 4
gpt4 key购买 nike

SecondViewController 的代码

@IBAction func ContinueFunc(_ sender: AnyObject) {
if (NomeAziendaText.text != "" && NumeroBlocchiText.text != "" && NumeroMacroText.text != ""){
nome = NomeAziendaText.text!
na = Int(NumeroMacroText.text!)!
nb = Int(NumeroBlocchiText.text!)!
Azienda.inizia(name: nome, numbermacro: na, numberblocchi: nb)

self.performSegue(withIdentifier: "next", sender: nil)
}
else {NomeAziendaText.text = ""
NumeroBlocchiText.text = ""
NumeroMacroText.text = ""
LabelAvvisi.text = " Inserisci tutti i valori"
}

/*
// MARK: - Navigation*/

func prepare(for segue: UIStoryboardSegue, sender: Any?) {
print("pippa")

if (segue.identifier == "next"){
if let vc_destinazione = segue.destination as?{


vc_destinazione.stringaDiPassaggio = nome
}

}

// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}`

ThirdViewController 的代码

 import UIKit
class ThirdViewController: UIViewController {
var stringaDiPassaggio: String = String()
var numero: Int = 0
@IBOutlet var Bottone: UIButton!
@IBOutlet var myLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
print(stringaDiPassaggio)
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func FunzioneBottone(_ sender: AnyObject) {

}

}`

为什么没有数据从 SecondViewController 传递到 ThirdViewController?如果我重写 PrepareFor segue 方法,它会显示一个错误,表明我没有重写父类(super class)的任何方法

请帮帮我

最佳答案

确保您已连接 View Controller 并更正此错误

          performSegueWithIdentifier("next", sender: self)

然后改正这个

 if (segue.identifier == "next"){
if let vc_destinazione = segue.destination as! ThirdViewController {


vc_destinazione.stringaDiPassaggio = nome
}

}

关于ios - 覆盖 prepareForSegue 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39664398/

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