I am looking for UIPageViewController and found this:
http://www.ioslearner.com/implementing-uipageviewcontroller-programatically-without-storyboarding/
It’s suspicious. Why does it insert an array of just 1 viewController initially.
So I made a program trying to insert 2-10. The program works if I just insert 1 viewController initially. However, if I try to insert 2-10, it doesn’t work.
[self.containerView addSubview:self.pageViewController.view];
self.pageViewController.view.frame = self.containerView.bounds;
NSMutableArray * arrayOfControllers=[NSMutableArray array];
for (int i = 0; i<1 ; i++) { //if I set this into for (int i = 0; i<10 ; i++) { instead it wouldn't work
BlankImageViewController *contentViewController = [[BlankImageViewController alloc] init];
contentViewController.view.frame = self.containerView.bounds;
[arrayOfControllers addObject:contentViewController];
//contentViewController.labelContents = [self.modelArray objectAtIndex:0];
}
NSArray *viewControllers = @[arrayOfControllers.lastObject];
viewControllers = [NSArray arrayWithArray:arrayOfControllers]; //If this line is commented it works
[self.pageViewController setViewControllers:viewControllers
direction:UIPageViewControllerNavigationDirectionForward
animated:YES
completion:nil];
If viewControllers have only one element it works. self.pageViewController.viewControllers will be filled with that 1 element.
if viewControllers have more than one element, then things do not work anymore. self.pageViewController.viewControllers will have empty array.
I wonder why. I am new to UIPageViewController. If you can only fill one UIViewController why ask for an array?
If you have just one page at a time showing, there is one view controller. If you have two pages at a time showing, there are two view controllers.
By the way, my book teaches you to get started with Page View Controller:
http://www.apeth.com/iOSBook/ch19.html#_page_view_controller
But I haven’t updated it yet for iOS 6 and the new scroll transition style.