UIPageViewController和landscape [英] UIPageViewController and landscape

查看:123
本文介绍了UIPageViewController和landscape的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试以下内容并且没有任何工作

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

pageViewOptions的NSlog是2,spineLocation的NSlog是1.这让我起了作用,我想做的就是在中间用脊椎初始化。它始终在左侧初始化。应用程序初始化为横向,但只有在旋转设备180度之后方法
- (UIPageViewControllerSpineLocation)pageViewController:(UIPageViewController *)pageViewController spineLocationForInterfaceOrientation:(UIInterfaceOrientation)orientation
工作,然后我得到脊椎中间。有人可以对此有所了解。我到处寻找答案。

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

推荐答案

尝试使用options参数:

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

...

并且不要忘记初始化2个内容视图控制器:

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

这篇关于UIPageViewController和landscape的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆