Reputation: 6723
I have 3 UIViews inside my ViewController and I want to place inside each UICiew a different ViewController.
I know that there is a way of adding a ChildViewcontroller and then assigning childviewcontroller.view
to the view that I need.
Is there another way of what I need ?
Upvotes: 3
Views: 1028
Reputation: 8833
Adding as a child view controller is the correct way to do it. that way you will still be getting life cycle functionality to the child view controllers.
addChildViewController(controller)
controller.view.frame = ...
view.addSubview(controller.view)
controller.didMoveToParentViewController(self)
I would advice you to use the ViewControllers by them self, there is no need for a UIView, and then a UIViewController on top.. (Maybe you have a speciel scenario that you must, but I can't think of one...)
Good luck
Upvotes: 1