我有一个函数可以正确地更改视图,但它不会将变量传递给下一个视图。我不是Swift的专家,我不知道我的代码中的错误在哪里:

let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let newViewController = storyBoard.instantiateViewController(withIdentifier: "PaymentVC") as! PaymentViewController
self.present(newViewController, animated: true, completion: nil)
    newViewController.num_pal = num_words
    newViewController.l_origen = l_source
    newViewController.l_destino = l_target
    newViewController.espec = espec
    newViewController.user = user
    newViewController.pass = pass
    newViewController.texto = texto
    newViewController.modificado = modificado
    newViewController.texto_ant = texto_ant

非常感谢你的帮助。

最佳答案

self.present(newViewController, animated: true, completion: nil)应该是在传递数据之后,把它放在newViewController.texto_ant = texto_ant之后

关于ios - 更改 View +以编程方式将变量发送到 View ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42693553/

10-10 20:29