title: Adding UIViewControllers to a UIScrollView
body: <p>Right, this may not be possible but maybe it it...</p>
  
  <p>I have 3 UIViewControllers, each with their own XIB files which contain the layout for each slide of a presentation (each slide will contain video, images, other interactive elements). I have hooked them all up to a UIScrollView by adding them one by one, see below:</p>
  
  <pre><code>page1 *vc = [[page1 alloc] initWithNibName:@"page1" bundle:nil];
  vc.view.frame = CGRectMake(0.0f, 0.0f, 1024.0f, 768.0f);
  [sv addSubview:vc.view];
  [vc release];
  page2 *vc2 = [[page2 alloc] initWithNibName:@"page2" bundle:nil];
  vc.view.frame = CGRectMake(1024.0f, 0.0f, 1024.0f, 768.0f);
  [sv addSubview:vc2.view];
  [vc2 release];
  page3 *vc3 = [[page3 alloc] initWithNibName:@"page3" bundle:nil];
  vc.view.frame = CGRectMake(2 * 1024.0f, 0.0f, 1024.0f, 768.0f);
  [sv addSubview:vc3.view];
  [vc3 release];
  </code></pre>
  
  <p>What I want to be able to do is create an array of UIViewController and loop around the array to add them, rather than one by one. First off, I can't seem to create an array of UIViewControllers, my code is as follows:</p>
  
  <pre><code>NSArray *pages = [[NSArray alloc] initWithObjects:page1, page2, page3, nil];
  </code></pre>
  
  <p>and the error is: expected expression before 'page1'.</p>
  
  <p>I did manage to load up the UIViewControllers with the following code:</p>
  
  <pre><code>for (int i = 1; i &lt;= 3; i++) {
      UIViewController *vc = [[UIViewController alloc] initWithNibName:[NSString         stringWithFormat:@"page%i", i] bundle:nil];
      vc.view.frame = CGRectMake((i-1) * 1024.0f, 0.0f, 1024.0f, 768.0f);
      [sv addSubview:vc.view];
      [vc release];
  }
  </code></pre>
  
  <p>But even though the content from the XIBs was displayed, the viewDidLoad function of the loaded in UIViewControllers is never fired.</p>
  
  <p>So, does any one have any tips here for loading up an array of UIViewControllers into a UIScrollView?</p>
  
  <p>Thank you!</p>