5. Window,Views,ViewControllers
• Window
• Every application has at least one window
• Blank canvas to host views
• View
• Draw and animate content
• Layout subviews
• Receive and forward events
• View Controller
• Manages a self-contained view hierarchy
6. UIApplication
• Set up main run loop
• Manages event queue
• Custom behavior through delegation
• UIApplicationDelegation
7. View Controllers
• Every screen should have its own controller
• UIViewController implements much of the iOS
standard interface behavior
• Loading nib file
• Working with navigation, tab, and tool bars
• Composing multiple view controllers
• Handling events and memory warnings
• Managing interface orientation change
14. Type of View Controllers
• Custom view controller
• Directly express content on the screen
• Container view controller
• Manage other view controllers
• Usually does not express content directly
• Modal view controller
• Any view controller can be presented modally
86. ViewController.m (3/3)
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
if(self.blueViewController.view.superview==nil)
self.blueViewController = nil;
else
self.yellowViewController = nil;
}
多個畫⾯面的程式中,記憶體管理變得更加重要