Skip to content

Instantly share code, notes, and snippets.

@muhlenXi
Last active November 23, 2018 01:44
Show Gist options
  • Save muhlenXi/cd382fab42b8189f83beb39ed844f08c to your computer and use it in GitHub Desktop.
Save muhlenXi/cd382fab42b8189f83beb39ed844f08c to your computer and use it in GitHub Desktop.
一个 segue 的 prepare 方法 demo
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get navigation controller
let naviController = segue.destination as! UINavigationController
// Get view controller
let todoDetailController = naviController.topViewController as! TodoDetailTableViewController
if segue.identifier == "AddTodo" {
todoDetailController.title = "Add todo"
// Todo
}
if segue.identifier == "EditTodo" {
todoDetailController.title = "Edit todo"
// Todo like send value
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment