UPDATE 2

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

UPDATE 1

在IB中,如果我在模拟度量中 Select "导航栏",我的标签仍然会跳转.要在第一个屏幕上正确渲染标签,唯一的方法是不要将导航控制器设置为窗口的根视图控制器.

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

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

当我的应用程序加载时,初始视图中的内容会向下推一点,大小与导航栏大致相同.当我滚动pageViewController时,内容会跳到nib中的位置,pageViewController加载的所有其他ViewController都正常.

uipageviewcontroller with navigationcontroller

在我的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.因此,必须将automaticallyAdjustsScrollViewInsets设置为false.下面是我的viewDidLoad:

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.automaticallyAdjustsScrollViewInsets = false;

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

不需要在viewWillLayoutSubviews中添加任何内容(正如我之前的一个答案所建议的).

Objective-c相关问答推荐

在 10.9 上以编程方式启用对辅助设备的访问

是否需要 ARC 中的 NSNotificationCenter removeObserver?

在 viewDidAppear 之前无法正确设置框架

带有 IB_DESIGNABLE 的 UIButton 会引发运行时属性警告,并且不会在 Interface Builder 中呈现

NSInternalInconsistencyException: '无效参数不满足: !stayUp || CLClientIsBackgroundable(内部->fClient)'

arc4random 和 arc4random_uniform 有什么区别?

Objective-C 的文档生成器?

dispatch_async(dispatch_get_main_queue(), ^{...});等到完成?

当用户返回视图控制器时如何取消 Select uitableview 单元格

如何在 iOS 上将图像旋转 90 度?

将 NSData 字节转换为 NSString?

如何在表格视图中的两个单元格之间留出空间?

Objective-C:块 vs. Select 器 vs. 协议

self.window.rootViewController 与窗口 addSubview

如何在 ios 8 的 alertview 中添加文本输入?

Objective-C:前向类声明

在 Objective C 中,你能判断一个对象是否具有特定的属性或消息吗?

架构 i386 clang 的重复符号

Objective-C中的继承和类别有什么区别

Xcode没有编译任何项目? 'clang 失败,退出代码 255'