简体   繁体   中英

Adding subview leaves gap between subview and navigation bar

I've got a storyboard with a view wrapped in a navigationcontroller, that has a UI tab bar at the bottom. I dynamically add sub views to this view, but there is always a blank line between the navigation bar and the subview that appears to be the width of a status bar. On each of the subviews that are created on the storyboard I have their Simulated Metrics set to have a bottom bar as a Tab Bar, status bar is set to none, and top bar is set to navigation bar.

Below is my code for adding the sub view:

    if(!self.homeViewController){
         self.homeViewController = [self.storyboardinstantiateViewControllerWithIdentifier:@"HomeView"];        
    }

    if(self.currentViewController != self.homeViewController)
    {            
        [self.view insertSubview:self.homeViewController.view belowSubview:self.tabBar];
        [self.currentViewController removeFromParentViewController];
    }

    self.currentViewController = self.homeViewController;

On your homeViewController defined in Storyboard, set the 'Resize View From NIB' property to unticked (this is ticked by default). This cured the gap problem for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM