Adding subview leaves gap between subview and navigation bar

亡梦爱人 提交于 2020-01-05 07:32:49

问题


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;

回答1:


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.



来源:https://stackoverflow.com/questions/12310683/adding-subview-leaves-gap-between-subview-and-navigation-bar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!