3

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 ?

Alexey K
  • 6,537
  • 18
  • 60
  • 118

1 Answers1

1

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

MCMatan
  • 8,623
  • 6
  • 46
  • 85