Please note, this blog entry is from a previous course. You might want to check out the current one.
Lecture #5 covers the view-controller life cycle and multiple MVCs and finishes with another demo of the Matchismo card game.
viewDidLoad is a good place to hold setup code – but has not geometry set yet.
viewWillAppear is for geometry-related initialization, lazy execution and late updating.
“A view gets loaded only once, but can appear and disappear a lot.”
viewWillDisAppear is suitable to “remember” and “clean up”.
view{Will,Did}LayoutSubviews is suitable to react to geometry changes.
Autorotation is controlled by shouldAutorotate …
didReceiveMemoryWarning is called when memory gets scarce.
awakeFromNib is sent to all objects that come out of a storyboard. Because init functions are not called when objects derive from storyboards, setup code has to be placed in both methods.
The simplest way to have multiple MVCs is UITabBarController with lots of automatic magic … which is explained in detail …
The demo at the end of the lecture shows how to add a tab bar controller and the usage of NSUserDefaults.
The code of the demo including the sorting and data formating is available at Stanford and on github.
Slides are available on iTunes …..
The lecture is available at iTunes and is named “5. View Controller Lifecycle and Multiple MVCs (January 22, 2013)”.
One thought on “cs193p – Lecture #5 – View Controller Lifecycle and Multiple MVCs”