我一直在试着做以下的事情,但什么也没用
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);
pageviewoptions处的nslog为2,spinelocation处的nslog为1。这把我逼上了墙,我要做的就是在中间加上脊骨。它总是在左边缩写。该应用程序是在横向初始化,但只有在将设备旋转180度后,该方法
“—(uiPageViewControllersPineLocation)页面视图控制器:(uiPageViewController*)页面视图控制器SpineLocationForInterfaceOrientation:(uiInterfaceOrientation)方向”
工作,然后我的脊椎在中间。有人能帮我解释一下吗?我到处找答案。
我所要做的就是在风景中用一个中间有一个脊柱的字母缩写
最佳答案
尝试使用“选项”参数:
NSDictionary *options = (UIInterfaceOrientationIsLandscape(self.interfaceOrientation)) ? [NSDictionary dictionaryWithObject: [NSNumber numberWithInteger:UIPageViewControllerSpineLocationMid] forKey: UIPageViewControllerOptionSpineLocationKey] : nil;
self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:options];
...
不要忘记初始化2个内容视图控制器:
NSArray *viewControllers = [NSArray arrayWithObjects:contentViewController1, contentViewController2, nil];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];