iOS   发布时间:2022-05-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – 使用UINavigationController在UIPageViewController中下载内容大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

更新2 我一直在使用4英寸设备在iOS模拟器中运行和测试我的应用程序.如果我使用3.5英寸设备运行,标签不会跳转.在我的.xib中,在Simulated Metrics下,我将它设置为ReTina 4英寸全屏.知道为什么我只在4英寸设备上看到这个问题吗? 更新1 在IB中,如果我在模拟指标中选择“导航栏”,我的标签仍然会跳转.我可以在第一个屏幕上正确呈现标签的唯一方法是不将导航控制器设置为我的窗口
更新2

我一直在使用4英寸设备在iOS模拟器中运行和测试我的应用程序.如果我使用3.5英寸设备运行,标签不会跳转.在我的.xib中,在Simulated Metrics下,我将它设置为ReTina 4英寸全屏.知道为什么我只在4英寸设备上看到这个问题吗?

更新1

在IB中,如果我在模拟指标中选择“导航栏”,我的标签仍然会跳转.我可以在第一个屏幕上正确呈现标签的唯一方法是不将导航控制器设置为我的窗口的根视图控制器.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

我的窗口的rootViewController被设置为一个UINavigationController,其rootViewController嵌入了一个UIPageViewController.

当我的应用加载时,会显示初始视图,其内容会向下推一点,大小与导航栏大致相同.当我滚动pageViewController时,内容跳转它在nib中的位置,而pageViewController加载的所有其他viewControllers都可以.

在我的appDelegate中:

self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[ContainerViewController new]];

在ContainerViewController中:

- (void)viewDidLoad {

    [super viewDidLoad];

    self.pvc = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll
                                               navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal
                                                             options:nil];
    self.pvc.datasource = self;
    self.pvc.delegate = self;
    DetailViewController *detail = [DetailViewController new];
    [self.pvc setViewControllers:@[detail]
                       direction:UIPageViewControllerNavigationDirectionForWARD
                        animated:false
                      completion:nil];

    [self addChildViewController:self.pvc];
    [self.view addSubview:self.pvc.view];
    [self.pvc didMoveToParentViewController:self];
}

解决方法

所以我在进一步开发后又添加了另一个答案,我终于想到了我发现了什么.好像在iOS7中,UIPageViewController似乎有自己的UIScrollView.因此,您必须将automaticAdjustsScrollViewInsets设置为false.这是我的viewDidLoad现在:

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.automaticallyAdjustsScrollViewInsets = false;

    DetailViewController *detail = [[DetailViewController alloc] init];
    [self setViewControllers:@[detail]
                   direction:UIPageViewControllerNavigationDirectionForWARD
                    animated:false
                  completion:nil];
}

无需在viewWillLayoutSubviews中添加任何内容(作为我之前建议的答案之一).

@H_673_54@
@H_874_60@

大佬总结

以上是大佬教程为你收集整理的ios – 使用UINavigationController在UIPageViewController中下载内容全部内容,希望文章能够帮你解决ios – 使用UINavigationController在UIPageViewController中下载内容所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。