El contenido cae debajo de la barra de navegación cuando está integrado en el controlador de vista de contenedor personalizado.

ACTUALIZAR

Basándome en la respuesta de Tim, implementé lo siguiente en cada controlador de vista que tenía una vista de desplazamiento (o subclase) que formaba parte de mi contenedor personalizado:

- (void)didMoveToParentViewController:(UIViewController *)parent
{
    if (parent) {
        CGFloat top = parent.topLayoutGuide.length;
        CGFloat bottom = parent.bottomLayoutGuide.length;

        // this is the most important part here, because the first view controller added 
        // never had the layout issue, it was always the second. if we applied these
        // edge insets to the first view controller, then it would lay out incorrectly.
        // first detect if it's laid out correctly with the following condition, and if
        // not, manually make the adjustments since it seems like UIKit is failing to do so
        if (self.collectionView.contentInset.top != top) {
            UIEdgeInsets newInsets = UIEdgeInsetsMake(top, 0, bottom, 0);
            self.collectionView.contentInset = newInsets;
            self.collectionView.scrollIndicatorInsets = newInsets;
        }
    }

    [super didMoveToParentViewController:parent];
}

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

Tengo un controlador de vista de contenedor personalizado llamadoSegmentedPageViewController. Puse esto como unUINavigationController's rootViewController.

El propósito deSegmentedPageViewController es permitir unUISegmentedControl, establecido como el título View del NavController, para cambiar entre diferentes controladores de vista secundarios.

Todos estos controladores de vista secundarios contienen una vista de desplazamiento, vista de tabla o vista de colección.

Estamos descubriendo que el primer controlador de vista se carga bien, colocado correctamente debajo de la barra de navegación. Pero cuando cambiamos a un nuevo controlador de vista, la barra de navegación no se respeta y la vista se establece debajo de la barra de navegación.

Estamos usando el diseño automático y el generador de interfaz. Hemos intentado todo lo que podemos imaginar, pero no podemos encontrar una solución consistente.

Aquí está el bloque de código principal responsable de configurar el primer controlador de vista y cambiar a otro cuando un usuario toca el control segmentado:

- (void)switchFromViewController:(UIViewController *)oldVC toViewController:(UIViewController *)newVC
{
    if (newVC == oldVC) return;

    // Check the newVC is non-nil otherwise expect a crash: NSInvalidArgumentException
    if (newVC) {

        // Set the new view controller frame (in this case to be the size of the available screen bounds)
        // Calulate any other frame animations here (e.g. for the oldVC)
        newVC.view.frame = self.view.bounds;

        // Check the oldVC is non-nil otherwise expect a crash: NSInvalidArgumentException
        if (oldVC) {
            // **** THIS RUNS WHEN A NEW VC IS SET ****
            // DIFFERENT FROM FIRST VC IN THAT WE TRANSITION INSTEAD OF JUST SETTING


            // Start both the view controller transitions
            [oldVC willMoveToParentViewController:nil];
            [self addChildViewController:newVC];

            // Swap the view controllers
            // No frame animations in this code but these would go in the animations block
            [self transitionFromViewController:oldVC
                              toViewController:newVC
                                      duration:0.25
                                       options:UIViewAnimationOptionLayoutSubviews
                                    animations:^{}
                                    completion:^(BOOL finished) {
                                        // Finish both the view controller transitions
                                        [oldVC removeFromParentViewController];
                                        [newVC didMoveToParentViewController:self];
                                        // Store a reference to the current controller
                                        self.currentViewController = newVC;
                                    }];
        } else {

            // **** THIS RUNS WHEN THE FIRST VC IS SET ****
            // JUST STANDARD VIEW CONTROLLER CONTAINMENT

            // Otherwise we are adding a view controller for the first time
            // Start the view controller transition
            [self addChildViewController:newVC];

            // Add the new view controller view to the view hierarchy
            [self.view addSubview:newVC.view];

            // End the view controller transition
            [newVC didMoveToParentViewController:self];

            // Store a reference to the current controller
            self.currentViewController = newVC;
        }
    }

}

Respuestas a la pregunta(5)

Su respuesta a la pregunta