UIViewController has several methods that get called at certain times:
viewWillAppear: when its view is about to be added to the window
viewDidAppear: when its view has been added to the window
viewWillDisappear: when its view is about to be dismissed, covered, or otherwise hidden from view
viewDidDisappear: when its view has been dismissed, covered, or otherwise hidden from view