Question

This very helpful tutorial shows how to use "Container View" properly. I only have a simple question: What if i don't know how many possible "subviews" I'll have to manage?
All the sub-views will have the same template (known at design time... lets say its a label only), but i don't know how many of them there will be... How would I adapt this to handle this scenario?

Was it helpful?

Solution

The container view controller's view will always have the same subviews. For example, a UINavigationController's view always has three subviews: the nav bar, the toolbar and the content view. Any view controller that's added to it puts it's view into the navigation controller's content view. All the further subviews belong to the view of the VC that's been added.

The view controller that's added to a container view controller takes care of it's own hierarchy of views. The container view controller takes care of resizing the contained view controller's main view. When the contained view controller's main view is resized, it takes care of resizing its own hierarchy of views.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top