带有 UIPageViewController 的 UIPopoverController 不显示任何内容

编程入门 行业动态 更新时间:2024-10-27 17:10:09
本文介绍了带有 UIPageViewController 的 UIPopoverController 不显示任何内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

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

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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-29 02:23:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1183573.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:内容   UIPageViewController   UIPopoverController

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!