2

Sorry I am new to this. I am trying to write an ipad app, with a page flipping effect. My app only support landscape view, and I have been testing UIPageViewController on the default Page-Based application project. Everything seems fine, but I want to have each page displaying only 1 viewController (even in landscape), by having the spine on the left. I tried

NSDictionary *options =  [NSDictionary dictionaryWithObject:
    [NSNumber numberWithInteger:UIPageViewControllerSpineLocationMin]
         forKey: UIPageViewControllerOptionSpineLocationKey];
self.pageViewController = [[UIPageViewController alloc] 
    initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl
    navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal 
    options:options];

But the spine is still in the middle, and displaying two view controllers at once... I've looked all over the web, but cannot find a solution. Please help.

P.S. Does anyone know how to use the Page View Controller object from storyboard? Even the example from xcode don't use it.

I found where the problem is. In the rootViewController, there is a

- (UIPageViewControllerSpineLocation)pageViewController:(UIPageViewController *)pageViewController spineLocationForInterfaceOrientation:(UIInterfaceOrientation)orientation

method, which override the spineLocation. remove everything and keep

UIViewController *currentViewController = [self.pageViewController.viewControllers objectAtIndex:0];
NSArray *viewControllers = [NSArray arrayWithObject:currentViewController];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:NULL];

self.pageViewController.doubleSided = NO;
return UIPageViewControllerSpineLocationMin;

solves the problem.

But still wondering... does anyone manage to sort out how to do UIPageViewController on storyboard?

hook38
  • 3,899
  • 4
  • 32
  • 52

0 Answers0