使用UINavigationController在UIPageViewController中下载内容 [英] Content pushed down in a UIPageViewController with UINavigationController

查看:134
本文介绍了使用UINavigationController在UIPageViewController中下载内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新2

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

I've been running and testing my app in the iOS Simulator using a 4-inch device. If I run using a 3.5-inch device the label doesn't jump. In my .xib, under Simulated Metrics, I have it set as Retina 4-inch Full Screen. Any idea why I'm only seeing this problem on a 4-inch device?

UPDATE 1

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

In IB, if I choose "Navigation Bar" in Simulated Metrics, my label still jumps. The only way I can get my label to render correctly on the first screen is to not set a navigation controller as my window's root view controller.

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

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

我的窗口的rootViewController正被设置为UINavigationController,其rootViewController嵌入了UIPageViewController。

My window's rootViewController is being set to a UINavigationController whose rootViewController has a UIPageViewController embedded.

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

When my app loads, the initial view is presented with it's content pushed down a bit, roughly the same size as a navigation bar. When I scroll the pageViewController, the content jumps up to where it was placed in the nib, and all other viewControllers loaded by the pageViewController are fine.

在我的appDelegate中:

In my appDelegate:

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

在ContainerViewController中:

In 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 现在:

So I'm adding another answer after further development and I finally think I figured out what's going on. Seems as though in iOS7, UIPageViewController has its own UIScrollView. Because of this, you have to set automaticallyAdjustsScrollViewInsets to false. Here's my viewDidLoad now:

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.automaticallyAdjustsScrollViewInsets = false;

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

无需在中添加任何内容viewWillLayoutSubviews (正如我之前建议的答案之一)。

No need to put anything in viewWillLayoutSubviews (as one of my previous answers suggested).

这篇关于使用UINavigationController在UIPageViewController中下载内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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