Graphics Programs Reference
In-Depth Information
need to implement viewDidUnload to release subviews of a view controller's view. In
TimeViewController.m , you can delete the implementation of this method.
- (void)viewDidUnload
{
[super viewDidUnload];
NSLog(@"timeLabel = %@", timeLabel);
}
Appearing and disappearing views
In addition to loading and unloading, the view of a view controller also appears and dis-
appears at certain times. UIViewController has several methods that get called at
these points in the lifecycle:
viewWillAppear:
when its view is about to be added to the window
viewDidAppear:
when its view has been added to the window
viewWillDisappear:
when its view is about to be dismissed, covered, or otherwise hidden from view
viewDidDisappear:
when its view has been dismissed, covered, or otherwise hidden from view
These methods are useful because a view controller is only created once, but its view usu-
ally gets displayed (and dismissed or hidden) several times. You often need a way to over-
ride the default behavior at these times in the life of view controller. For example, you
may want to do some sort of initialization each time the view is moved on screen, like dis-
playing the most current time in TimeViewController 's view. Here you would use
viewWillAppear: or viewDidAppear: .
 
Search WWH ::




Custom Search