繁体   English   中英

NavigationBar在TabBarViewController中隐藏TableView

[英]NavigationBar hides TableView in TabBarViewController

我有一个ViewController推TabBarViewController。 在该TabBar View Controller中,我有4个选项卡。 这些选项卡栏中的两个是UITableViewControllers,另外两个是ViewController。 第一个选项卡是一个表视图控制器,并且工作正常,即未被导航栏隐藏。 第三个选项卡是另一个TableViewController,被导航栏部分覆盖。 第一部分和第一个单元格隐藏在导航栏下方。 过去有人遇到过这个问题吗?有人知道解决方案吗? 我已经尝试了一些方法,例如手动调整帧大小

self.tableView.frame = CGRectMake(10,10,self.view.bounds.size.width -20, self.view.bounds.size.height-20);

那似乎没有用。 我也尝试过AutoLayout,但没有用。 我不知道该怎么办 任何人都对如何解决此问题有任何建议或想法。

编辑:我已经尝试了edgesForExtendedLayout但它使我的导航edgesForExtendedLayout更深。 它可以对导航栏中的颜色变化进行动画处理,就像加载栏一样。

注意:这仅在ios7中发生。 我只是在iOS 6.1中对其进行了模拟,并且导航栏根本没有涵盖表格视图控制器,这对我来说很奇怪。 有人有什么建议吗?

编辑#2:注意到这是iOS 7>问题,我做了以下操作,但现在导航栏的颜色已更改为较暗的颜色。

if([[[[UIDevice currentDevice] systemVersion] componentsSeparatedByString:@"."][0] intValue] >= 7)
    {
        if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
        {
            self.edgesForExtendedLayout = UIRectEdgeNone;
            self.extendedLayoutIncludesOpaqueBars = YES;
            self.automaticallyAdjustsScrollViewInsets = NO;
        }
    }

在UITableViewController的viewDidLoad方法中(假定它已加载对tabBarController的调用),该方法与选项卡相关联

if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) {
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.tableView.contentInset = UIEdgeInsetsMake(0., 0., CGRectGetHeight(self.tabBarController.tabBar.frame), 0);
}

我用以下方法修复了该问题:

if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) {
    viewcontroller.edgesForExtendedLayout = UIRectEdgeNone;
    viewcontroller.extendedLayoutIncludesOpaqueBars = NO;
    viewcontroller.automaticallyAdjustsScrollViewInsets = NO;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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