所以在我的1stViewController中我有这个代码:
@IBAction func colorDropdown(_ sender: Any) {
self.popUpColorPicker()
}
func popUpColorPicker() {
let popOverVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "ColorPicker") as! ColorPicker
self.addChildViewController(popOverVC)
popOverVC.view.frame = self.view.frame
self.view.addSubview(popOverVC.view)
popOverVC.didMove(toParentViewController: self)
}
会弹出2ndViewController。在解除弹出的2ndViewController后,我想检索输入的值并在第一个视图控制器中使用它。
最佳答案
您可以使用delegate
或completion handler
来实现这一点。
只需创建一个委托来处理有关解除second VC
的数据。
**
或者
**
写一个completion handler
closure
来获取第一个view controller
中的值。
关于ios - 如何将值从弹出 View Controller 传递到上一个 View Controller ?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41012508/