Skip to content

Instantly share code, notes, and snippets.

@muhlenXi
Last active November 22, 2018 11:24
Show Gist options
  • Save muhlenXi/663574396829d2b6cd75e13333a4c216 to your computer and use it in GitHub Desktop.
Save muhlenXi/663574396829d2b6cd75e13333a4c216 to your computer and use it in GitHub Desktop.
Segue 正、反向传值
// 正向传值
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let identifier = segue.identifier {
if identifier == "ToBeauty" {
let desVC = segue.destination as! BeautyViewController
let index = pickerView.selectedRow(inComponent: 0)
desVC.imageName = imageNames[index]
desVC.name = names[index]
}
}
}
// 反向传值 需要拖动事件 Action 到 ViewController Exit中
@IBAction func back (unwindSegue: UIStoryboardSegue) {
print("backed")
let sourceVC = unwindSegue.source as! BeautyViewController
print(sourceVC.reverseValue)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment