i have same question like this
1:Keep previous pages in UIPageViewController,但这里的答案是关于使用3 uipageviewcontroller ..如何做到这一点。对于内部页面我正在使用uipageviewcontroller的一个实例,如下面的代码没有storyboard。
self.pageViewController = [[UIPageViewController alloc]initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl navigationOrientation:UIPageViewControllerNavigationOrientationVertical options:[NSDictionary dictionaryWithObjectsAndKeys:@"2",UIPageViewControllerOptionSpineLocationKey,@"0",UIPageViewControllerOptionInterPageSpacingKey, nil]];
self.pageViewController.dataSource = self;
PageContentViewController *startingViewController = [self viewControllerAtIndex:0];
PageContentViewController *secondViewController = [self viewControllerAtIndex:1];
viewControllers = @[startingViewController,secondViewController];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
self.pageViewController.doubleSided = YES;
self.pageViewController.view.frame = CGRectMake(100,(self.view.frame.size.height-240)/2,self.view.frame.size.width-200, 240);
[self addChildViewController:self.pageViewController];
[self.view addSubview:self.pageViewController.view];
[self.pageViewController didMoveToParentViewController:self];
#pragma mark - Page View Controller Data Source and delegate
- (UIPageViewControllerSpineLocation)pageViewController:(UIPageViewController *)pageViewController spineLocationForInterfaceOrientation:(UIInterfaceOrientation)orientation
{
if(UIInterfaceOrientationIsPortrait(orientation))
{
//Set the array with only 1 view controller
PageContentViewController *startingViewController = [self viewControllerAtIndex:0];
viewControllers = [NSArray arrayWithObject:startingViewController];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:NULL];
self.pageViewController.doubleSided = NO;
return UIPageViewControllerSpineLocationMin;
}
else
{
PageContentViewController *startingViewController = [self viewControllerAtIndex:0];
PageContentViewController *secondViewController = [self viewControllerAtIndex:1];
viewControllers = @[startingViewController,secondViewController];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
self.pageViewController.doubleSided = YES;
return UIPageViewControllerSpineLocationMid;
}
}
- (NSUInteger)pageViewControllerSupportedInterfaceOrientations:(UIPageViewController *)pageViewController NS_AVAILABLE_IOS(7_0)
{
return UIInterfaceOrientationMaskLandscapeLeft ;
}
-(UIInterfaceOrientation)pageViewControllerPreferredInterfaceOrientationForPresentation:(UIPageViewController *)pageViewController NS_AVAILABLE_IOS(7_0)
{
return UIInterfaceOrientationLandscapeLeft;
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController
{
NSUInteger index = ((PageContentViewController*) viewController).pageIndex;
if ((index == 0) || (index == NSNotFound))
{
return nil;
}
index--;
NSLog(@"IndexBackNumber = %d",index);
return [self viewControllerAtIndex:index];
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController
{
NSUInteger index = ((PageContentViewController*) viewController).pageIndex;
if (index == NSNotFound) {
return nil;
}
index++;
if (index == [self.pageImages count])
{
return nil;
}
NSLog(@"IndexNumber = %d",index);
return [self viewControllerAtIndex:index];
}
这段代码给了我简单的效果,比如打开的书,我可以翻页,但我想要书的封面和封底,当内页翻页时,它可以翻转和保留。与上述链接问题中显示的相同。谢谢。