The following superclass methods may be added to a #ViewController.m file
//*******************************
//*******************************
//********** LOAD VIEW **********
//*******************************
//*******************************
//View being loaded (happens only when view is initially loaded or reloaded in memory)
- (void)loadView
{
[super loadView];
}
//***********************************
//***********************************
//********** VIEW DID LOAD **********
//***********************************
//***********************************
//View has loaded (happens only when view is initially loaded or reloaded in memory)
- (void)viewDidLoad
{
[super viewDidLoad];
}
//**************************************
//**************************************
//********** VIEW WILL APPEAR **********
//**************************************
//**************************************
//View about to be added to the window (called each time it appears)
//Occurs after other view's viewWillDisappear
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
//... your code
}
//*************************************
//*************************************
//********** VIEW DID APPEAR **********
//*************************************
//*************************************
//View has been added to the window (called each time it appears)
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
//... your code
}
//*****************************************
//*****************************************
//********** VIEW WILL DISAPPEAR **********
//*****************************************
//*****************************************
//View is about to be dismissed, covered or otherwise hidden from view (called each time it disappers)
//Occurs before other view's viewWillAppear
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
//... your code
}
//****************************************
//****************************************
//********** VIEW DID DISAPPEAR **********
//****************************************
//****************************************
//View has been dismissed, covered or otherwise hidden from view (called each time it disappers)
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
//... your code
}
//**************************
//**************************
//********** INIT **********
//**************************
//**************************
- (id) init
{
[super init];
return self;
}
UIViewController Important Rules
1 – Never manipulate the view in the init method. This is only called once when the the view controller is created, but the view is not necessarily shown then. The view may also be released and re-created if memory becomes full. Use the loadView and viewDidLoad methods instead.
2 – Any outlets you set in Interface Builder must be released and set to nil in viewDidUnload. They must also be released in dealloc. This is necessary in case the view is unloaded because of say low memory, otherwise it will not be correctly deallocated.