Search code examples
iosuinavigationbariphone-x

uiviewcontroller embeded in uinavigation controller starts under parent view's navigation bar in iphone x


enter image description hereenter image description here

I am using following code to add child view controller within another viewcontroller.

  CGRect rightViewFrame = CGRectMake(0, 0, self.view.bounds.size.width,self.view.bounds.size.height-50);
    
    [pWorksetController viewDidAppear:YES];
    
    UIStoryboard *pModelViewStoryboard = [UIStoryboard storyboardWithName:@"ModelViewMobile" bundle:nil];
   gpUserDataManager.pModelViewController =
    (ModelViewController*)[pModelViewStoryboard  instantiateViewControllerWithIdentifier:@"VIEW_DETAIL"];
    // pModelViewController.selectedModel = pModelListInfo;
    gpUserDataManager.pModelViewController.DiscussionViewListingDelegate = self;
    //offline model
    gpUserDataManager.pModelViewController.syncAllButton = self.syncAllButton;
    //offline model
    //[self UpdateView];
    gpUserDataManager.pModelViewController.modelViewDelegate = self;
    gpUserDataManager.pModelViewController.navigationController.navigationItem.hidesBackButton =TRUE;
    self.pRightNavController = [[UINavigationController alloc] initWithRootViewController:gpUserDataManager.pModelViewController];
    [self.pRightNavController.view setFrame:rightViewFrame];
    self.pRightNavController.view.layer.cornerRadius = 5.0;
    self.pRightNavController.view.clipsToBounds =  YES;
    self.pRightNavController.navigationBar.translucent = NO;
    [self.view addSubview:self.pRightNavController.view];  
    [self addChildViewController:self.pRightNavController];

Childviewcontroller's navigation is not starting from proper position.It comes under navigation bar.Please see attached screenshot-1.This only happens while running application on iphone x.It looks properly in other devices.How to resolve this?

Update: When i uncheck under top bars and bottom bars it shifts uiviewcontroller below.Please refer to second screenshot-2.


Solution

  • Just uncheck:

    Under Top Bars 
    Under Bottom Bars 
    

    enter image description here