I’m trying to implement a page-scroll functionality in my project. I develop for iOS 5, with storyboards (and ARC). This is what I did in my storyboard :

The first viewController (on the left) has a scrollView and a pageControl. Its class is called GlobalDashboardViewController, and inherits from the class DashboardViewController (which inherits from UIViewController). The other 2 controllers are simple UIViewControllers with identifiers (MainDashboard and SecondaryDashboard).
In GlobalDashboardViewController.m, there is only a viewDidLoad, which gets the childViewControllers :
- (void)viewDidLoad
{
[super viewDidLoad];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"MainDashboard"]];
[self addChildViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"SecondaryDashboard"]];
}
DashboardViewController.m is a bit more complex. Here are the most important methods :
- (void)viewDidLoad
{
// Calling the viewDidLoad above to populate the childViewControllers array
[super viewDidLoad];
[self.scrollView setPagingEnabled:YES];
[self.scrollView setScrollEnabled:YES];
[self.scrollView setShowsHorizontalScrollIndicator:NO];
[self.scrollView setShowsVerticalScrollIndicator:NO];
[self.scrollView setDelegate:self];
}
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.pageControl.currentPage = 0;
_page = 0;
[self.pageControl setNumberOfPages:[self.childViewControllers count]];
UIViewController *viewController = [self.childViewControllers objectAtIndex:self.pageControl.currentPage];
if (viewController.view.superview != nil) {
[viewController viewWillAppear:animated];
}
self.scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * [self.childViewControllers count], scrollView.frame.size.height);
}
There are plenty of other methods, but I don’t think they’re relevant, because here is my problem: the app launches, and I see the scrollView and the pageControl. The background is dark gray, as I set it in the GlobalDashboard viewController. I can scroll correctly, and the pageControl is updated. But I don’t see the other views. When I place a breakpoint at the if in viewWillAppear, and look at viewController, it’s named correctly (Dashboard Page 1, which is the name I gave to the controller in the storyboard), but its _view property shows 0x00000000, as you can see here :

So, I never get inside the if, which is where some of the magic of actually showing the viewControllers happens…
My work is based on an example project you can find here : PageViewController. When I run it, it works perfectly. I have no clue why I can’t make it work in my own project.
Any ideas ?
Thanks
You never add the view itself (
[self.view addSubview:/*Your child controller's view*/]). The project you linked to does it in- (void)loadScrollViewWithPage:(int)pageinside PagerViewController.m