Skip to content

Instantly share code, notes, and snippets.

@vvit
Last active October 14, 2017 21:39
Show Gist options
  • Save vvit/ea529816bef49a9ff00fb2b4f4ffd815 to your computer and use it in GitHub Desktop.
Save vvit/ea529816bef49a9ff00fb2b4f4ffd815 to your computer and use it in GitHub Desktop.
// Check if a view controller is popped from navigation stack (either by `popViewController` or interactive transition)
// Method 1
override func didMove(toParentViewController parent: UIViewController?) {
super.didMove(toParentViewController: parent)
if parent == nil { // parent is `nil` when the vc is popped
}
}
// Method 2
override func viewDidDisappear(animated: Bool) {
super.viewDidDisappear(animated)
if self.isBeingDismissed() || self.isMovingFromParentViewController() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment