title: Adding UIViewcontrollers to UIScrollview
body: <p>I am changing the layout of an existing application. There are a series of view which now needs to be added to a scrollview that the users can swipe to move to next screen. I have added the controllers to scrollview using the code below. </p>
  
  <blockquote>
    <p>This code is added  in the viewDidLoad of the Viewcontroller which
    holds the UIScrolliew</p>
  </blockquote>
  
  <p>.</p>
  
  <pre><code>int i=1;
  int width = 0,height=0;
  for(POTCTask *task in [CommonData tasks])
  {
      UIViewController&lt;TaskViewController&gt; *controller = [TaskViewFactory getTaskViewController:(task.inputTypeId)];
      width = controller.view.frame.size.width;
      height = controller.view.frame.size.height;
      controller.view.frame = CGRectMake(width*(i-1), 0, width, height);
      [self.scrollView addSubview:controller.view];
      i++;
  }
  self.scrollView.contentSize = CGSizeMake(width*i, height);
  </code></pre>
  
  <p>It loads all view fine. But only the viewDidLoad is getting called in each viewcontroller. No other methods are getting called And some have UItableviews in it. But its showing only the first cell.</p>
  
  <p>How can I do this properly in ios?</p>
  
  <p>Thanks</p>