61loadView vs. viewDidLoad
viewDidLoad
only if the view is unarchived from a nib, method is invoked after view is set.
loadView
only invoked when the view
proberty is nil
. use when creating views programmatically. default: create a UIView object with no subviews.
- (void)loadView {
UIView *view = [[UIView alloc] initWithFrame:[UIScreen
mainScreen].applicationFrame];
[view setBackgroundColor:_color];
self.view = view;
[view release];
}
By implementing the loadView method, you hook into the default memory management behavior. If memory is low, a view controller may receive the didReceiveMemoryWarning
message. The default implementation checks to see if the view is in use. If its view is not in the view hierarchy and the view controller implements the loadView method, its view is released. Later when the view is needed, the loadView method is invoked
again to create the view.