- (void)viewDidLoad {
self.pageController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
self.pageController.dataSource = self;
[[self.pageController view] setFrame:CGRectMake(0, 0, self.viewParent.frame.size.width, self.viewParent.frame.size.height)];
initialViewController = [self viewControllerAtIndex:[[NSUserDefaults standardUserDefaults] integerForKey:#"indexAllQuestion"]];
viewControllers = [NSArray arrayWithObject:initialViewController];
[self.pageController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
[self addChildViewController:self.pageController];
[[self viewParent] addSubview:[self.pageController view]];
[self.pageController didMoveToParentViewController:self];
self.pageController.delegate = self;
self.pageController.dataSource = self;
}
- (AllComponentQuestionViewController *)viewControllerAtIndex:(NSUInteger)index {
current_question = self.all_question_keys[index];
AllComponentQuestionViewController *childViewController = [[AllComponentQuestionViewController alloc] initCurrent_question:current_question initCurrent_worksheet:current_worksheet iniTotalQuestion:maxDataCount];
[childSwipeVC replaceObjectAtIndex:index withObject:childViewController];
childViewController.indexChild = index;
return childViewController;}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController {
NSUInteger index = [(AllComponentQuestionViewController *)viewController indexChild];
if ((index == NSNotFound) || index <= 0) {
index = 0;
return nil;
}
else{
index--;
return [self viewControllerAtIndex:index];
}
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController {
NSUInteger index = [(AllComponentQuestionViewController *)viewController indexChild];
if (index >= maxDataCount) {
index = maxDataCount;
return nil;
}
else{
index++;
return [self viewControllerAtIndex:index];
}}
http://pasted.co/de8d5246 this link same like that
The case is:
Swipe right from index 0 to index 1
the index increase index to 2, so my index +2
if i swipe again it will +1
and tell if now i'm in index 8, i swipe left
the index will decrease to -6, so my index -2
and if i swipe left again it will index-- or index = index - 2
need help in advance, stuck in here in a week ago
Thank You
viewControllerAfterViewController: and viewControllerBeforeViewController: are UIPageViewControllerDataSource methods, which are invoked by UIPageViewController's internal controller
The reason why those methods are called twice with 1 swipe, is that, for example, if you swipe to the right (or go forward), it will prepare next view controller and another one in advance for you, so therefore, if you are needed to have exact index that user is currently on, you should probably need to have delegate methods for getting the current index when swiping, like:
Objective-C:
- (void)pageViewController:(UIPageViewController *)pageViewController
willTransitionToViewControllers:(NSArray<UIViewController *> *)pendingViewControllers;
Swift 4:
func pageViewController(_ pageViewController: UIPageViewController,
willTransitionTo pendingViewControllers: [UIViewController])
and
Objective-C:
- (void)pageViewController:(UIPageViewController *)pageViewController
didFinishAnimating:(BOOL)finished
previousViewControllers:(NSArray<UIViewController *> *)previousViewControllers
transitionCompleted:(BOOL)completed;
Swift 4:
func pageViewController(_ pageViewController: UIPageViewController,
didFinishAnimating finished: Bool,
previousViewControllers: [UIViewController],
transitionCompleted completed: Bool)
For example, user can swipe to the right, but the transition will not fall through, and the pageViewController swipe will return to previous index automatically, therefore you need to use completed param to see if index is changed or not, etc..
Read more here: https://developer.apple.com/reference/uikit/uipageviewcontrollerdelegate/1614090-pageviewcontroller?language=objc
Related
How does one ensure that the viewWillAppear: and viewDidAppear: (and other view transition methods) are called on a UIPageViewController's child ViewControllers?
In my case, the view transition methods are adequately called on all except for the very firstViewController that the UIPageViewController opens to. On that firstViewController, the viewDidAppear: and viewWillAppear: methods are actually called BEFORE the UIPageViewController's view transition methods. And then as one starts scrolling, the viewWillAppear: and viewDidAppear: methods are called as one would expect for the new view controllers.
Here is my structure: I have a BossViewController that contains an OrganizerViewController (a couple different organizers, actually, but that is irrelevant). The OrganizerViewController contains a UIPageViewController, which contains a series of CustomViewControllers. My code adequately calls the child view transition methods as per apple (https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/ImplementingaContainerViewController.html) for the interactions between the BossViewController and the OrganizerViewController (fully functional, perfectly so). The problem lies somewhere between the OrganizerViewController, it's child UIPageViewController, and it's first child CustomPageViewController.
I have tried calling beginAppearanceTransition: and endAppearanceTransition: within the UIPageViewController's viewWillAppear: and viewDidAppear: - but that resulted in an 'unbalanced calls' error log to console.
Here is the UIPageViewController set up code, all of which is in the OrganizerViewController:
- (void)configurePVC
{
NSDictionary *key = #{UIPageViewControllerOptionInterPageSpacingKey : #([UIScreen mainScreen].bounds.size.width * 0.5)};
_pvc = [[AVSCustomPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll
navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:key];
self.pvc.delegate = self;
self.pvc.dataSource = self;
_pvcArray = [[NSMutableArray alloc] init];
CustomViewController *daily = (CustomViewController *)[self viewControllerAtIndex:6];
self.index = 6;
[self.pvcArray addObject:daily];
[self.pvc setViewControllers:self.pvcArray
direction:UIPageViewControllerNavigationDirectionForward
animated:YES
completion:nil];
[self addChildViewController:self.pvc];
[self.dailyContainerView addSubview:self.pvc.view];
self.pvc.view.frame = self.dailyContainerView.bounds;
[self.pvc didMoveToParentViewController:self];
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController
{
NSUInteger index = [(CustomViewController *)viewController index];
if (index == 0) {
return nil;
}
index--;
return [self viewControllerAtIndex:index];
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController {
NSUInteger index = [(CustomViewController *)viewController index];
if (index == 6) {
return nil;
}
index++;
return [self viewControllerAtIndex:index];
}
- (UIViewController *)viewControllerAtIndex:(NSUInteger)index
{
CustomViewController *viewController = [[CustomViewController alloc] init];
viewController.index = index;
return viewController;
}
I have a UIPageViewController that I've set up with an array as the datasource. I see the first page fine and the presentation count dots show up correctly, but when I try to drag the to the next page nothing happens. So I set up some breakpoints in the viewControllerAfterViewController as well as Before methods and they never get called on. The other dataSource methods for presentationCountForPageViewController get called on fine.
Any idea what I am missing? I've been going line by line with examples I've found on the web but can't find anything.
- (void)viewDidLoad
{
[super viewDidLoad];
UIPageViewController *pageController = self.pageController;
pageController.dataSource = self;
UIChildViewController *initialViewController = [self viewControllerAtIndex:0];
NSArray *viewControllers = #[initialViewController];
[pageController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:nil];
[self addChildViewController:pageController];
[self.view addSubview:pageController.view];
[pageController didMoveToParentViewController:self];
}
- (UIPageViewController *)pageController
{
return !_pageController ? _pageController =
({
UIPageViewController *value = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll
navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal
options:nil];
value.view.frame = self.view.bounds;
value;
}) : _pageController;
}
- (UIViewController *)pageViewController:(UIPageViewController *)pa geViewController viewControllerBeforeViewController:(UIChildViewController *)viewController
{
NSUInteger index = viewController.index;
return (index == 0 ) ? nil : [self viewControllerAtIndex:--index];
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIChildViewController *)viewController
{
NSUInteger index = viewController.index;
index++;
return (index == self.myDataSourceArray.count) ? nil : [self viewControllerAtIndex:index];
}
- (UIChildViewController *)viewControllerAtIndex:(NSUInteger)index
{
UIChildViewController *childViewController = [UIChildViewController new];
childViewController.view.frame = self.pageController.view.bounds;
childViewController.index = index;
...
return childViewController;
}
- (NSInteger)presentationCountForPageViewController: (UIPageViewController *)pageViewController
{
// The number of items reflected in the page indicator.
return self.myDataSourceArray.count;
}
- (NSInteger)presentationIndexForPageViewController:(UI PageViewController *)pageViewController
{
// The selected item reflected in the page indicator.
return 0;
}
The problem was that in including my UIViewController subclass which encapsulated the UIPageViewController, I forgot in the parent view controller's viewDidLoad to include addChildViewController and didMoveToParentViewController
[self addChildViewController:myViewController];
[self.view addSubview:myViewController.view];
[myViewControllerController didMoveToParentViewController:self];
Fixed the problem.
I'm loading views into a UIPageViewController and scrolling through them horizontally.
My issue is that when a view enters screen, it has a bigger size, and when the scroll finishes, it snaps to the size it should have.
Been trying to figure this out for a couple of hours now.
Anyone has had the same problem? how did you solve it?
I've checked these 2 links:
UIPageViewController changes size?
UIPageViewController has strange size
That made sense, but on my case, by doing that, I made the views too big on smaller devices, feels like the constraints aren't working, so I'm getting the bigger size here
I am not sure but try this:
// Disalbe translatesAutoresizingMaskIntoConstraints
self.pageViewController.view.translatesAutoresizingMaskIntoConstraints = NO;
// Set up page view controller view constraints by using PureLayout
[self.pageViewController.view autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsZero]
please confine is it help ful or not ..
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController
{
ImageViewController *contentVc = (ImageViewController *)viewController;
NSUInteger currentIndex = [_modelArray indexOfObject:[contentVc model]];
_vcIndex = currentIndex;
[_rateStepper setValue:[[contentVc model] rating]];
ImageModel *model = [_modelArray objectAtIndex:_vcIndex];
[_imageLabel setText:[NSString stringWithFormat:#"%# - Rating: %d", model.imageName, model.rating]];
if (currentIndex == 0)
{
return nil;
}
ImageViewController *imageViewController = [[ImageViewController alloc] init];
imageViewController.model = [_modelArray objectAtIndex:currentIndex - 1];
return imageViewController;
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController
{
ImageViewController *contentVc = (ImageViewController *)viewController;
NSUInteger currentIndex = [_modelArray indexOfObject:[contentVc model]];
_vcIndex = currentIndex;
[_rateStepper setValue:[[contentVc model] rating]];
ImageModel *model = [_modelArray objectAtIndex:_vcIndex];
[_imageLabel setText:[NSString stringWithFormat:#"%# - Rating: %d", model.imageName, model.rating]];
if (currentIndex == _modelArray.count - 1)
{
return nil;
}
ImageViewController *imageViewController = [[ImageViewController alloc] init];
imageViewController.model = [_modelArray objectAtIndex:currentIndex + 1];
return imageViewController;
}
If you build and run now, the pages will scroll, however we are still missing the page indicator view. We only need to implement the following dataSource methods as below:
- (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController
{
return _modelArray.count;
}
- (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController
{
return 0;
}
I've been trying to use the UIPageViewController to display 3 different nibs for a few days on and off now and have almost got it working. I still have one weird bug that I cant figure out.
Basically the app starts, I can scroll between the 3 pages one after another with out any problems, eg:
Page1->Page2->Page3
and then back to the start:
Page3->Page2->Page1.
No Problems. The issue is that if I scroll, for example from Page3->Page2, then BACK to Page3, Page3 Dissappears when it snaps into place. If I scroll to where a forth page would be, then I get Page3. Here is the code relevant to the UIPageViewController, the nibs and the delegate methods for the UIPageViewController:
- (void)viewDidLoad{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
self.pageViewController.delegate = self;
[[self.pageViewController view] setFrame:[[self view] bounds]];
indexTest = 0;
Page1 *p1 = [[Page1 alloc]initWithNibName:#"Page1" bundle:nil];
p1.view.tag = 1;
Page2 *p2 = [[Page2 alloc]initWithNibName:#"Page2" bundle:nil];
p2.view.tag = 2;
Page3 *p3 = [[Page3 alloc]initWithNibName:#"Page3" bundle:nil];
p3.view.tag = 3;
NSArray *arr = [[NSArray alloc] initWithObjects:p1,nil];
viewControllers = [[NSMutableArray alloc] initWithObjects:p1,p2,p3, nil];
[self.pageViewController setViewControllers:arr direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
self.pageViewController.dataSource = self;
[self addChildViewController:self.pageViewController];
[[self view] addSubview:[self.pageViewController view]];
[self.pageViewController didMoveToParentViewController:self];
self.view.gestureRecognizers = self.pageViewController.gestureRecognizers;
}
#pragma mark - page view controller stuff
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController {
if (indexTest > 0) {
switch (indexTest) {
case 1:{
NSLog(#"NO page is BEFORE current page");
break;
}
case 2:{
NSLog(#"Page BEFORE is Page: %#", [NSString stringWithFormat:#"%#",[viewControllers objectAtIndex:0] ] );
indexTest--;
return [viewControllers objectAtIndex:0];
break;
}
default:{
NSLog(#"PROBLEM in viewBEFORE, indexTest = %d!!!!", indexTest);
break;
}
}
}
return nil;
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController {
if (indexTest < NUM_OF_PAGES) {
switch (indexTest) {
case 0:{
NSLog(#"Page AFTER is Page: %#", [NSString stringWithFormat:#"%#",[viewControllers objectAtIndex:1] ] );
indexTest++;
return [viewControllers objectAtIndex:1];
break;
}
case 1:{
NSLog(#"Page AFTER is Page: %#", [NSString stringWithFormat:#"%#",[viewControllers objectAtIndex:2] ] );
indexTest++;
return [viewControllers objectAtIndex:2];
break;
}
case 2:{
NSLog(#"No pages AFTER this current page %d", indexTest);
break;
}
default:{
NSLog(#"PROBLEM in viewAFTER, indexTest = %d!!!!", indexTest);
break;
}
}
}
return nil;
}
Finally the page index dots code
#pragma mark - dot controller
- (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController {
// The number of items reflected in the page indicator.
return NUM_OF_PAGES;
}
- (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController {
// The selected item reflected in the page indicator.
return 0;
}
Any and all help is much appreciated, I think I'm just doing something silly that I cant see as I'm so close to it fully working. If anythings not clear or I haven't give enough information please let me know and I'll answer it as best as I can.
Thanks
I think your indexTest logic is wrong, it's showing the wrong indexes for the viewControllers. I wouldn't use those methods to keep track of the index as they can be called even when the views aren't actually going to change.
Instead you could replace the selection of view controllers like this:
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController {
int vcIndex = [self.viewControllers indexOfObject:viewController];
if (vcIndex > 0) {
return [self.viewControllers objectAtIndex:vcIndex-1];
}
return nil;
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController {
int vcIndex = [self.viewControllers indexOfObject:viewController];
if (vcIndex < NUM_OF_PAGES-1) {
return [self.viewControllers objectAtIndex:vcIndex+1];
}
return nil;
}
And if you need to keep track of the current index, use the delegate method provided.
- (void)pageViewController:(UIPageViewController *)pageViewController didFinishAnimating:(BOOL)finished previousViewControllers:(NSArray *)previousViewControllers transitionCompleted:(BOOL)completed {
if (completed && finished) {
UIViewController *currentVC = pageViewController.viewControllers[0];
indexTest = [self.viewControllers indexOfObject:currentVC];
}
}
Just note that if your using this method, don't call setViewControllers: amimated:YES as this will lose track of the correct position.
Side note: I too have been struggling with UIPageViewController and found it was quicker and easier to write my own version. I think it has too many bugs.
I m using UIPageViewController on iPad where I need to show a firstviewController in the first page and ContentViewController in the next page in landscape.
If I set the NSArray with two viewControllers the app is crashes at [self.pagviewController setViewController:] with the following exception:
The number of provided view controllers (2) doesn't match the number required (1) for the requested spine location (UIPageViewControllerSpineLocationMin)
Below is the code:
#pragma mark - UIPageViewControllerDataSource Methods
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController
viewControllerBeforeViewController:(UIViewController *)viewController
{
NSUInteger currentIndex = [self.modelArray indexOfObject:[(ContentViewController *)viewController textContents]];
if(currentIndex == 0)
{
return nil;
}
ContentViewController *contentViewController = [[ContentViewController alloc] init];
contentViewController.textContents = [self.modelArray objectAtIndex:currentIndex - 1];
return contentViewController;
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController
viewControllerAfterViewController:(UIViewController *)viewController
{
NSUInteger currentIndex = [self.modelArray indexOfObject:[(ContentViewController *)viewController textContents]];
if(currentIndex == self.modelArray.count-1)
{
return nil;
}
ContentViewController *contentViewController = [[ContentViewController alloc] init];
contentViewController.textContents = [self.modelArray objectAtIndex:currentIndex + 1];
return contentViewController;
}
//#pragma mark - UIPageViewControllerDelegate Methods
- (UIPageViewControllerSpineLocation)pageViewController:(UIPageViewController *)pageViewController
spineLocationForInterfaceOrientation:(UIInterfaceOrientation)orientation
{
if(UIInterfaceOrientationIsPortrait(orientation))
{
//Set the array with only 1 view controller
UIViewController *currentViewController = [self.pageViewController.viewControllers objectAtIndex:0];
NSArray *viewControllers = [NSArray arrayWithObject:currentViewController];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:NULL];
//Important- Set the doubleSided property to NO.
self.pageViewController.doubleSided = NO;
//Return the spine location
return UIPageViewControllerSpineLocationMin;
}
else
{
NSArray *viewControllers = nil;
ContentViewController *currentViewController = [self.pageViewController.viewControllers objectAtIndex:0];
NSUInteger currentIndex = [self.modelArray indexOfObject:[(ContentViewController *)currentViewController textContents]];
if(currentIndex == 0 || currentIndex %2 == 0)
{
UIViewController *nextViewController = [self pageViewController:self.pageViewController viewControllerAfterViewController:currentViewController];
viewControllers = [NSArray arrayWithObjects:currentViewController, nextViewController, nil];
}
else
{
UIViewController *previousViewController = [self pageViewController:self.pageViewController viewControllerBeforeViewController:currentViewController];
viewControllers = [NSArray arrayWithObjects:previousViewController, currentViewController, nil];
}
//Now, set the viewControllers property of UIPageViewController
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:NULL];
return UIPageViewControllerSpineLocationMid;
}
}
- (void)viewDidLoad
{
[super viewDidLoad];
appDelegate = (AppDelegate *) [[UIApplication sharedApplication] delegate];
//Instantiate the model array
self.modelArray = [[NSMutableArray alloc] init];
self.vcs = [[NSMutableArray alloc]init];
for (int index = 1; index <= 2 ; index++)
{
[self.modelArray addObject:[NSString stringWithFormat:#"Page %d",index]];
}
//Step 1
//Instantiate the UIPageViewController.
self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl
navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
//Step 2:
//Assign the delegate and datasource as self.
self.pageViewController.delegate = self;
self.pageViewController.dataSource = self;
//Step 3:
//Set the initial view controllers.
appDelegate.contentViewController.textContents = [self.modelArray objectAtIndex:0];
NSArray *viewControllers = [NSArray arrayWithObjects:appDelegate.firstViewController,appDelegate.contentViewController,nil];
[self.pageViewController setViewControllers:viewControllers
direction:UIPageViewControllerNavigationDirectionForward
animated:NO
completion:nil];
//Step 4:
//ViewController containment steps
//Add the pageViewController as the childViewController
[self addChildViewController:self.pageViewController];
//Add the view of the pageViewController to the current view
[self.view addSubview:self.pageViewController.view];
//Call didMoveToParentViewController: of the childViewController, the UIPageViewController instance in our case.
[self.pageViewController didMoveToParentViewController:self];
//Step 5:
// set the pageViewController's frame as an inset rect.
CGRect pageViewRect = self.view.bounds;
pageViewRect = CGRectInset(pageViewRect, 40.0, 40.0);
self.pageViewController.view.frame = pageViewRect;
//Step 6:
//Assign the gestureRecognizers property of our pageViewController to our view's gestureRecognizers property.
self.view.gestureRecognizers = self.pageViewController.gestureRecognizers;
}
The problem is you passing an array containing two view controllers to the page view controller while it expects one at a time, change your array to be like this :
NSArray *viewControllers = #[appDelegate.firstViewController];
You will pass one of the views but viewControllerAfterViewController and viewControllerBeforeViewController will handle the rest.
Ah..Finally got solution for this same issue.., it may helps you..
When we set the spine location to UIPageViewControllerSpineLocationMid, the doubleSided property of the pageViewController is automatically set to YES. This means that the content on page front will not partially show through back. But when this property is set to NO, the content on page front will partially show through back, giving the page a translucent kind of effect. So, in the portrait orientation, we have to set the value to NO, otherwise it would result in an exception.
So in your UIPageviewcontroller delegate method, in else part add this doubleSided property as YES when you return spineLocation as UIPageViewControllerSpineLocationMid
self.pageViewController.doubleSided = YES;
return UIPageViewControllerSpineLocationMid;
self.pageViewController.doubleSided = NO;
return UIPageViewControllerSpineLocationMid;
This is the solution for the exception.
In xcode it self you could find this.
Go to the UIPageViewcontroller class there you could see the explanation for this like:
#property (nonatomic, readonly) UIPageViewControllerSpineLocation spineLocation; // If transition style is 'UIPageViewControllerTransitionStylePageCurl', default is 'UIPageViewControllerSpineLocationMin', otherwise 'UIPageViewControllerSpineLocationNone'.
// Whether client content appears on both sides of each page. If 'NO', content on page front will partially show through back.
// If 'UIPageViewControllerSpineLocationMid' is set, 'doubleSided' is set to 'YES'. Setting 'NO' when spine location is mid results in an exception.
#property (nonatomic, getter=isDoubleSided) BOOL doubleSided; // Default is 'NO'.
Instead of implementing a full data source, you can set the PageViewController with one view controller at a time each time the user pushes a next or back button, like
[pageViewController setViewControllers:#[contentViewController]
direction:UIPageViewControllerNavigationDirectionForward
animated:YES
completion:nil];
This will animate the page transition as you switch.