Skip to content

Instantly share code, notes, and snippets.

@jeksys
Created June 13, 2019 18:30
Show Gist options
  • Save jeksys/238575ab9a90fb5f72d2bb5125b183ca to your computer and use it in GitHub Desktop.
Save jeksys/238575ab9a90fb5f72d2bb5125b183ca to your computer and use it in GitHub Desktop.
Source of view appear calls
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if isMovingToParent {
print("isMovingToParent")
// this view controller is becoming visible because it was just push onto a navigation controller or some other container view controller
} else if isBeingPresented {
print("isBeingPresented")
// this view controller is becoming visible because it is being presented from another view controller
} else if view.window == nil {
print("view.window == nil ")
// this view controller is becoming visible for the first time as the window's root view controller
} else {
print("else")
// this view controller is becoming visible because something that was covering it has been dismissed or popped
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment