I wanted to use a Container View to initiate another view controller, but I can’t see to find any information on how to alloc it programmly. I can do it from the user interface, but if I want to create one with the coes, and link it up to a UIviewController, how can I do that? Does it behave like a normal UIview?
Share
If I follow your question, you’re asking how to use view controller containment in code. I’d suggest checking out Creating Custom Container View Controllers section of the View Controller Programming Guide, which shows you code for doing this, including adding a child view controller:
When using child view controllers (at least ones that don’t take up the whole screen), it’s useful to have a
UIViewon the parent view controller’s view, that dictates the boundaries of the child view controller. It greatly simplifies a bunch of tasks. In the above code snippet, they’re assuming that the subview is calledframeForContentController.Or removing one (in this code snippet,
contentis theUIViewController *that references the child controller being removed):And if you want to replace a child controller with another child controller:
I’d also suggest checking out WWDC 2011 – Implementing UIViewController Containment.