5. What is a View Controller?
View Controller Overview
‣ Focal point of most iOS app development
‣ Key Responsibilities:
‣ Defines the application workflow
‣ Manages a view hierarchy
‣ Programmatically
‣ NIB and/or Storyboard
‣ Plays the MVC “Controller” role...
8. MVC Benefits
Core iOS Design Pattern
‣ Clean separation of concerns
‣ Simplifies development
‣ Provides for greater reusability
‣ Improves quality
‣ Allows us to standardize the behavior and
responsibilities at each tier
10. View Controller Types
Container vs Content
Container Controllers
‣ Manages a hierarchy of child view controllers
UITabBarController
UINavigationController
UISplitViewController
Content Controllers
‣ Manage the individual screens within an app
‣ Can be used in multiple presentation contexts
‣ Manages a “screenful of content”
21. How do you fix it?
Ugly Options
Create a MonstrosityController
Not practical
Create non-UIViewController controllers
Not scalable
Create container and forward callbacks
Incomplete and ugly
35. Disabling Auto Forwarding
Fine Tuning Containment
- (BOOL)automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers
{
return NO;
}
• Control timing of appearance and rotation callbacks
• Useful override in complex containment scenarios
46. Summary
View Controller Containment FTW!
‣ Simple, but subtle API. Easy to make mistakes.
‣ Need to understand UIViewController internals
‣ Small, but important, enhancements in iOS 6