Tag Archives: container

iOS howto work with container viewcontroller

http://www.thinkandbuild.it/working-with-custom-container-view-controllers/

CONCLUSIONS

Here’s a simple timeline scheme to resume the steps needed to attach a new child and remove the previous one. This is a common behaviour of almost all the navigation patterns you will build.
1 Current detail controller: [current willMoveToParentViewController:nil]
2 Next detail controller: [container addChildViewController:next]
2.B Next detail controller: [next willMoveToParentViewController:self] (Automatically called by point 2)
3 Next detail controller: [container.view addSubview:next.view]
4 Current detail controller: [current.view removeFromSuperView]
5 Current detail controller: [current removeFromParentViewController]
6 Current detail controller: [current didMoveToParentViewController:nil] (automatically called by point 5)
7 Next detail controller: [next didMoveToParentViewController:self]
You can build any navigation pattern whatsoever just using these “new” functions. Some really good examples of Container Controllers are obviously the UINavigationController and UITabBarController. They have different logics and different usages but they have in common the final result of showing the user one View Controller at a time.
Another example of Container Controller is the UISplitViewController that is able to show two Controllers at the same time .
In a few words, your custom Container has essentially the responsibility to define which controllers have to be shown and how the user can move between Controllers.

http://www.apeth.com/iOSBook/ch19.html