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
- viewWillDisappear – use for cleaning up and saving states
viewWillLayoutSubviews and viewDidLayoutSubviews can be used to adjust layouts in addition to autolayout.
viewWillTransitionToSize allows animations alongside the rotation animation from 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.