从以前的VIew控制器获取数据

问题描述 投票:1回答:2

我试图从我的上一个视图控制器获取值。我在上一个视图中有一个TextField,我希望该文本在我的下一个视图控制器中继续。假设我在TextField中写“5”,我希望它在我的下一个视图中显示在标签上。这可能吗,我该怎么做?

delegates swift2 segue viewcontroller message-passing
2个回答
2
投票

您需要的是prepareForSegue(),您可以获取所需的所有信息并将其发送到下一个ViewController


2
投票
let vc = self.storyboard?.instantiateViewControllerWithIdentifier("YOUR_IDENTIFIER") as! YOUR_CONTROLLER

//Setup the properties
vc.PROPERTY = "DATA"   //this property variable has to be there in your destination view controller

self.presentViewController(vc, animated: true, completion: nil)

或者你可以使用prepareForSegue:

© www.soinside.com 2019 - 2024. All rights reserved.