2

对不起,我是新手。我正在尝试编写一个具有翻页效果的 ipad 应用程序。我的应用程序仅支持横向视图,并且我一直在默认的基于页面的应用程序项目上测试 UIPageViewController。一切似乎都很好,但我希望每个页面只显示 1 个 viewController(即使在横向),通过在左侧放置脊椎。我试过了

NSDictionary *options =  [NSDictionary dictionaryWithObject:
    [NSNumber numberWithInteger:UIPageViewControllerSpineLocationMin]
         forKey: UIPageViewControllerOptionSpineLocationKey];
self.pageViewController = [[UIPageViewController alloc] 
    initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl
    navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal 
    options:options];

但是脊椎仍然在中间,并且一次显示两个视图控制器......我已经查看了整个网络,但找不到解决方案。请帮忙。

PS 有谁知道如何使用情节提要中的页面视图控制器对象?即使是来自 xcode 的示例也不使用它。

我发现问题出在哪里。在 rootViewController 中,有一个

- (UIPageViewControllerSpineLocation)pageViewController:(UIPageViewController *)pageViewController spineLocationForInterfaceOrientation:(UIInterfaceOrientation)orientation

方法,它覆盖了spineLocation。删除所有内容并保留

UIViewController *currentViewController = [self.pageViewController.viewControllers objectAtIndex:0];
NSArray *viewControllers = [NSArray arrayWithObject:currentViewController];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:NULL];

self.pageViewController.doubleSided = NO;
return UIPageViewControllerSpineLocationMin;

解决问题。

但仍然想知道......有没有人设法理清如何在情节提要上做 UIPageViewController ?

4

0 回答 0