objective-c - UIPageViewController 和景观

标签 objective-c ipad ios5 uipageviewcontroller

我一直在尝试以下方法,但没有任何效果

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。这让我很困惑,我只想用中间的 spine 初始化。它总是在左边初始化。该应用程序以横向方式初始化,但仅在将设备旋转 180 度后才使用该方法 “- (UIPageViewControllerSpineLocation)pageViewController:(UIPageViewController *)pageViewController spineLocationForInterfaceOrientation:(UIInterfaceOrientation)orientation” 工作,然后我在中间得到脊柱。有人可以对此有所了解吗?我到处寻找答案。

我想要它做的就是在风景中初始化,中间有一个脊椎

最佳答案

尝试使用“options”参数:

NSDictionary *options = (UIInterfaceOrientationIsLandscape(self.interfaceOrientation)) ? [NSDictionary dictionaryWithObject: [NSNumber numberWithInteger:UIPageViewControllerSpineLocationMid] forKey: UIPageViewControllerOptionSpineLocationKey] : nil; 

self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:options];

...

并且不要忘记初始化 2 个内容 View Controller :

NSArray *viewControllers = [NSArray arrayWithObjects:contentViewController1, contentViewController2, nil];

[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];

关于objective-c - UIPageViewController 和景观,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9246572/

相关文章:

iphone - 使用我的 GPS 位置对位置的 NSMutableArray 进行排序

ios - iOS8 中的多行/动态 UILabel 截断

iphone - 如何从 iPhone 模拟器录制电影?

ios - 将地址转换为经度和纬度

iphone - 旋转 iOS 6 兼容 iOS 5

iphone - 谁能帮我通过 Audio Unit 录制 iPhone 输出的声音

ios - 我怎样才能访问图层以便翻转它?

ios - 如何比较 PHAsset 和 UIImage

iphone - NSOperation 和 NSInvocationOperation 之间的区别?

iphone - 如何处理不在 UINavigationController 堆栈顶部的 UIViewController 的旋转?