I have been trying the following and nothing is working
NSDictionary *pageViewOptions = [NSDictionary dictionaryWithObjectsAndKeys:UIPageViewControllerOptionSpineLocationKey, [NSNumber numberWithInteger:UIPageViewControllerSpineLocationMid],nil];
NSLog(@"pageViewOptions :%@",pageViewOptions);
self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:pageViewOptions];
NSLog(@"spineLocation :%d",self.pageViewController.spineLocation);
the NSlog at pageViewOptions is 2, NSlog at spineLocation is 1. This is driving me up the wall, all i want to do is initialise with spine in the middle. It always initialises on the left. the app is initialised in landscape but only after rotating the device 180 degrees the method "- (UIPageViewControllerSpineLocation)pageViewController:(UIPageViewController *)pageViewController spineLocationForInterfaceOrientation:(UIInterfaceOrientation)orientation" works and then i get spine in the middle. could someone please shed some light on this. I've searched everywhere for an answer.
all i want it to do is initialise in landscape with a spine in the middle
Try to use "options" parameter:
NSDictionary *options = (UIInterfaceOrientationIsLandscape(self.interfaceOrientation)) ? [NSDictionary dictionaryWithObject: [NSNumber numberWithInteger:UIPageViewControllerSpineLocationMid] forKey: UIPageViewControllerOptionSpineLocationKey] : nil;
self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:options];
...
And don't forget to initialize 2 content view controllers:
NSArray *viewControllers = [NSArray arrayWithObjects:contentViewController1, contentViewController2, nil];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With