iOS engineer who likes clean, simple designs and sans-serif.

Loading

The View Controller LifeCycle

From Paul Hagerty’s Stanford Lecture #5, here is the order in which things happen in a View Controller’s lifecycle:

  • View controller is instantiated (from storyboard, etc.)
  • awakeFromNib
  • Outlets are set
  • viewDidLoad
  • (When geometry is determined)
    • viewWillLayoutSubviews: and viewDidLayoutSubviews:
  • (As MVC appears and reappears, this could happen multiple times)
    • viewWillAppear: and viewDidAppear:
    • (Whenever geometry changes while visible, eg device rotation)
      • viewWillLayoutSubviews: and viewDidLayoutSubviews
      • (if it is autorotation, then you also get will/didRotateTo/From messages, but rare to use these)
    • viewWillDisappear: and viewDidDisappear:
  • (If memory gets low)
  • didReceiveMemoryWarning

Leave a Comment