cs193p – Lecture #8 View Controller Lifecycle, Autolayout

By Timo Springer (de:Benutzer:Inquisitor) [GFDL (http://www.gnu.org/copyleft/fdl.html), CC-BY-SA-3.0 (http://creativecommons.org/licenses/by-sa/3.0/), GFDL (http://www.gnu.org/copyleft/fdl.html) or CC-BY-SA-3.0 (http://creativecommons.org/licenses/by-sa/3.0/)], via Wikimedia Commons

Please note, this blog entry is from a previous course. You might want to check out the current one.

View Controller Lifecycle

  • viewDidLoad is called after instantiation and outlet setting (geometry is not set yet!) – use for setup
  • viewWillAppear is called before the view appears on screen (geometry is available) – use for layout setup and updates which happened while the view was off screen
  • viewDidAppear
  • viewWillDisappear – use for cleaning up and saving states
  • viewDidDisappear

Geometry changed

viewWillLayoutSubviews and viewDidLayoutSubviews can be used to adjust layouts in addition to autolayout.
viewWillTransitionToSize allows animations alongside the rotation animation from autolayout.

Autolayout

Autolayout provides provides the means to layout items for different view sizes. Size classes provide allow different autolayouts depending on the device types.

The lecture and its slides are available via iTunes named “8. View Controller Lifecycle, Autolayout”. The code for the psychologist demo is available on GitHub and at Stanford. The code for the autolayout demo is available on GitHub and at Stanford. The code for the ShowSizeClass demo is available at Stanford.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

3 thoughts on “cs193p – Lecture #8 View Controller Lifecycle, Autolayout”

  1. I updated to the newest version of Swift and when I try “extension User {}” I get an error “declaration is only valid at file scope”

    Any ideas why?

  2. Can anyone describe in detail what’s going on in User.swift ?
    I am trying to understand it but can’t understand how he created the database dictionary?
    How is he validating the login text?
    And why struct is chosen over class?

Leave a Reply

Your email address will not be published.