带有 UIPageViewController 的 UIPopoverController 不显示任何内容 [英] UIPopoverController with UIPageViewController shows no content

查看:30
本文介绍了带有 UIPageViewController 的 UIPopoverController 不显示任何内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I try to show views of different view controllers within a popover controller's view. I tried for three hours now but without success. Basically this is what I've done:

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

这就是我看到的:

我在这里遗漏了什么?

推荐答案

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

Ok, if someone encounters a similar problem, I solved it:

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

It seems that right after initialization you have to set exactly the number of view controllers that are needed at a time.

因此,如果您创建一个 UIPageViewController,一次显示一个页面,请在 setViewControllers:direction:animated:completion:setViewControllers:direction:animated:completion:代码>.不止一个导致我的控制器不显示任何内容.稍后可以通过实现 UIPageViewControllerDelegateUIPageViewControllerDataSource 协议来延迟添加其他视图控制器.

So, if you create a UIPageViewController with one page displayed at a time, put an array containing exactly(!) one view controller in setViewControllers:direction:animated:completion:. More than one caused my controller to display nothing. Other view controllers can later be added lazily by implementing the UIPageViewControllerDelegate and UIPageViewControllerDataSource protocols.

这篇关于带有 UIPageViewController 的 UIPopoverController 不显示任何内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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