添加子视图会在子视图和导航栏之间留下空白 [英] Adding subview leaves gap between subview and navigation bar

查看:143
本文介绍了添加子视图会在子视图和导航栏之间留下空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含在导航控制器中的视图的故事板,底部有一个UI标签栏。我动态添加子视图到此视图,但导航栏和子视图之间始终有一个空白行,显示为状态栏的宽度。在故事板上创建的每个子视图上,我将其模拟指标设置为将底部栏设置为选项卡栏,状态栏设置为无,顶部栏设置为导航栏。

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;


推荐答案

在Storyboard中定义的homeViewController,查看从NIB'属性到未命中(默认情况下已勾选)。这解决了我的差距问题。

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.

这篇关于添加子视图会在子视图和导航栏之间留下空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆