View Controller Lifecycle

A view controller has a series of “lifecycle” methods that are called at various stages. When the view controller is initially set up, viewDidLoad is called. As it is shown and hidden, viewWillAppear, viewDidAppear, viewWillDisappear, and viewDidDisappear will be called. The appearance and disappearance are split into two methods because sometimes you want some behavior to happen before the transition animation starts or after the transition animation ends.

override func viewWillAppear(animated: Bool) {
println("view will appear")

override func viewDidAppear(animated: Bool) {
println("view did appear")

override func viewWillDisappear(animated: Bool) {
println("view will disappear")

override func viewDidDisappear(animated: Bool) {
println("view did disappear")

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s