Can anyone point me to any good examples of creating a Custom View Controller as a Container View Controller? The only documentation I can find is a couple of paragraphs in the UIViewController Class Reference. I feel I need a little more information than that and an example implementation would be nice. Google has turned up nothing at all.
I am specifically interested in the method:
transitionFromViewController:toViewController:duration:options:animations:completion:
Container view controllers are a way to combine the content from multiple view controllers into a single user interface. Container view controllers are most often used to facilitate navigation and to create new user interface types based on existing content.
A view controller manages a single root view, which may itself contain any number of subviews. User interactions with that view hierarchy are handled by your view controller, which coordinates with other objects of your app as needed. Every app has at least one view controller whose content fills the main window.
Unlike a content view controller that displays your app's data, a container view controller displays other view controllers, arranging them onscreen and handling navigation between them. A container view controller is still a view controller, so you display it in a window or present it like any other view controller.
The UIViewController class defines the shared behavior that's common to all view controllers. You rarely create instances of the UIViewController class directly. Instead, you subclass UIViewController and add the methods and properties needed to manage the view controller's view hierarchy.
The best thing I have found so far is the WWDC 2011 Session Video Session 102 - Implementing UIViewController Containment.
In addition to the WWDC Session Video Session 102 - Implementing UIViewController Containment that hypercrypt already mentioned, Apple WWDC 2012 session on "The Evolution of View Controllers on iOS" also covers this topic and the example code is part of the sample code package:
https://developer.apple.com/devcenter/download.action?path=/wwdc_2012/wwdc_2012_sample_code/wwdc_2012_session_code.dmg
There's also an example here: https://github.com/toolmanGitHub/stackedViewControllers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With