2

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
  • 5,649
  • 16
  • 51
  • 102

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
  • 7,411
  • 4
  • 36
  • 73