修正方法はこんな感じです。
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController {
DSBookletPageViewController *currentVC = (DSBookletPageViewController *)viewController;
NSUInteger currentIndex = [currentVC index];
if(currentIndex >= self.modelArray.count-1) {
if (currentIndex %2 == 0 && !isPortrait) {
//return an empty one
DSBookletPageViewController *newVC = [[DSBookletPageViewController alloc] init];
[newVC setIndex:currentIndex+1];
return newVC;
} else {
return nil;
}
}
currentIndex ++;
UIImage *currentPage = [self.modelArray objectAtIndex:currentIndex];
DSBookletPageViewController *newVC = [[DSBookletPageViewController alloc] initWithImage:currentPage andOrientation:isPortrait];
[newVC setIndex:currentIndex];
return newVC;
}
モデル配列の外部のUIPageViewControllerに別のページを追加しているので、基本的に配列の最後にいるか、それを超えているかを確認します。私がそこにいて、現在のインデックスが偶数で、縦向きでない場合は、ページを追加します。そうでない場合は、nilを返します。
それがお役に立てば幸いです。