参见英文答案 >
Perform Segue programmatically and pass parameters to the destination view5个
我以编程方式调用segue,任何人都可以帮助我如何传递参数?
我以编程方式调用segue,任何人都可以帮助我如何传递参数?
@IBAction func update(sender: AnyObject) { self.performSegueWithIdentifier("showUpdate",sender: nil) }
解决方法
斯威夫特4:
override func prepare(for segue: UIStoryboardSegue,sender: Any?) { if segue.identifier == "ExampleSegueIdentifier" { if let destinationVC = segue.destination as? ExampleSegueVC { destinationVC.exampleStringProperty = "Example" } } }
斯威夫特3:
override func prepareForSegue(segue: UIStoryboardSegue,sender: AnyObject?) { if segue.identifier == "ExampleSegueIdentifier" { if let destinationVC = segue.destinationViewController as? ExampleSegueVC { destinationVC.exampleStringProperty = "Example" } } }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。