Lecture 8 View Controller Lifecycle, Autolayout

View Controller Lifecycle

  1. Instantiated (from storyboard usually)
  2. awakeFromNib
  3. segue preparation happens
  4. outlets get set
  5. viewDidLoad
  6. viewWillAppear & viewDidAppear
  7. viewWillDisappear & viewDidDisappear
  8. viewWillLayoutSubviews & viewDidLayoutSubviews
  9. didReceiveMemoryWarning

Autolayout

Size Classes

iPhone 6+

  • Portrait: Compact in width and Regular in height
  • Landscape: Compact in height and Regular in width

iPhone

  • Portrait: Compact in width and Regular in height
  • Landscape: Compact in width and Compact in height

iPad

  • Always Regular in both dimensions.
  • An MVC that is the master in a side-by-side split view will be Compact width, Regular height.

Extensible

  • This whole concept is extensible to any “MVC’s inside other MVC’s” situation (not just split view).
  • An MVC find out its size class environment via this method in UIViewController

  • The return value is an enum .Compact or .Regular (or .Unspecified).

Leave a Reply

Your email address will not be published. Required fields are marked *