1

我尝试在弹出控制器的视图中显示不同视图控制器的视图。我现在尝试了三个小时,但没有成功。基本上这就是我所做的:

- (IBAction)buttonTapped:(id)sender {

    NSDictionary *options = [NSDictionary dictionaryWithObject: [NSNumber numberWithInteger:UIPageViewControllerSpineLocationMin] forKey:UIPageViewControllerOptionSpineLocationKey];
    UIPageViewController *pageVC = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:options];
    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"MainStoryboard_iPad" 
                                             bundle:[NSBundle mainBundle]];
    UIViewController *firstVC = [sb instantiateViewControllerWithIdentifier:@"FirstTableViewController"];
    UIViewController *secondVC = [sb instantiateViewControllerWithIdentifier:@"SecondViewController"];
    NSArray *viewControllers = [[NSArray alloc] initWithObjects:firstVC, secondVC, nil];
    [pageVC setViewControllers:viewControllers direction:UIPageViewControllerTransitionStylePageCurl animated:NO completion:nil];

    UIButton *button = sender;
    UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:pvc];               
    [popover presentPopoverFromRect:button.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}

这就是我看到的:

在此处输入图像描述

我在这里想念什么?

4

1 回答 1

2

好的,如果有人遇到类似的问题,我解决了:

似乎在初始化之后,您必须准确设置一次所需的视图控制器的数量

因此,如果您创建一个UIPageViewController一次显示一个页面,请将一个包含完全(!)一个视图控制器的数组放入setViewControllers:direction:animated:completion:. 不止一个导致我的控制器什么也没显示。稍后可以通过实现UIPageViewControllerDelegateUIPageViewControllerDataSource协议来延迟添加其他视图控制器。

于 2012-05-27T15:54:00.247 回答