Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save susieyy/319ffadbf68ab33e2d36d1ecb813b4b5 to your computer and use it in GitHub Desktop.
Save susieyy/319ffadbf68ab33e2d36d1ecb813b4b5 to your computer and use it in GitHub Desktop.
Check if view controller is presented modally, or pushed on a navigation stack
// @see http://stackoverflow.com/a/23620428/1002412
// @see http://level49.com/119
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
if isBeingDismissed() {
// being dismissed
} else if isMovingFromParentViewController() {
// being poped
} else {
//
}
}
override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)
if isBeingPresented() {
// being presented
} else if isMovingFromParentViewController() {
// being pushed
} else {
// simply showing again because another VC was dismissed
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment