title: Learning UIPageControl using Apple's "PageControl"sample, need help modifying to add my view controllers
body: <p>Using the Apple "PageControl" as a template.  I'd like to know how to modify the code to use my view controllers that I have in my Storyboard.  Let's call the view controllers, one_vc, two_vc, three_vc.  The sample is using NULL for the view controllers.</p>
  
  <p>The full code is here: <a href="https://developer.apple.com/library/ios/#samplecode/PageControl/Introduction/Intro.html" rel="nofollow">Apple PageControl</a></p>
  
  <p>Thanks in advance</p>
  
  <p>-PaulS.</p>
  
  <pre><code>- (void)awakeFromNib
  {
      // load our data from a plist file inside our app bundle
      NSString *path = [[NSBundle mainBundle] pathForResource:@"content_iPhone" ofType:@"plist"];
  
      self.contentList = [NSArray arrayWithContentsOfFile:path];
  
      // view controllers are created lazily
      // in the meantime, load the array with placeholders which will be replaced on demand
      NSMutableArray *controllers = [[NSMutableArray alloc] init];
  
      for (unsigned i = 0; i &lt; kNumberOfPages; i++)
      {
          [controllers addObject:[NSNull null]];
      }
      self.viewControllers = controllers;
  
      [controllers release];
  
      // a page is the width of the scroll view
      scrollView.pagingEnabled = YES;
      scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * kNumberOfPages, scrollView.frame.size.height);
      scrollView.showsHorizontalScrollIndicator = NO;
      scrollView.showsVerticalScrollIndicator = NO;
      scrollView.scrollsToTop = NO;
      scrollView.delegate = self;
  
      pageControl.numberOfPages = kNumberOfPages;
      pageControl.currentPage = 1;
  
      // pages are created on demand
      // load the visible page
      // load the page on either side to avoid flashes when the user starts scrolling
      //
      [self loadScrollViewWithPage:0];
      [self loadScrollViewWithPage:1];
  }
  
  - (void)loadScrollViewWithPage:(int)page
  {
      if (page &lt; 0)
          return;
      if (page &gt;= kNumberOfPages)
          return;
  
      // replace the placeholder if necessary
      MyViewController *controller = [viewControllers objectAtIndex:page];
      if ((NSNull *)controller == [NSNull null])
      {
          controller = [[MyViewController alloc] initWithPageNumber:page];
          [viewControllers replaceObjectAtIndex:page withObject:controller];
          [controller release];
      }
  
     // add the controller's view to the scroll view
      if (controller.view.superview == nil)
      {
          CGRect frame = scrollView.frame;
          frame.origin.x = frame.size.width * page;
          frame.origin.y = 0;
          controller.view.frame = frame;
          [scrollView addSubview:controller.view];
  
          NSDictionary *numberItem = [self.contentList objectAtIndex:page];
          controller.numberImage.image = [UIImage imageNamed:[numberItem valueForKey:ImageKey]];
          controller.numberTitle.text = [numberItem valueForKey:NameKey];
      }
  }
  </code></pre>