UIPageViewController and Terrain

I tried the following and nothing works

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); 

NSlog on the ViewOptions page is 2, NSlog on spineLocation is 1. This pushes me against the wall, and all I want to do is initialize with the spine in the middle. It is always initialized on the left. the application is initialized in the landscape, but only after turning the device 180 degrees the method "- (UIPageViewControllerSpineLocation) pageViewController: (UIPageViewController *) pageViewController spineLocationForInterfaceOrientation: (UIInterfaceOrientation) orientation" works, and then I get the spine in the middle. can someone shed some light on this. I searched everywhere for an answer.

all i want to do is initialize in the landscape with the spine in the middle

+4
source share
1 answer

Try using the "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 two content controllers:

 NSArray *viewControllers = [NSArray arrayWithObjects:contentViewController1, contentViewController2, nil]; [self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil]; 
+8
source

Source: https://habr.com/ru/post/1395999/


All Articles