【问题标题】:NavigationBar hides TableView in TabBarViewControllerNavigationBar 在 TabBarViewController 中隐藏 TableView
【发布时间】:2013-10-22 09:49:08
【问题描述】:

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

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

这似乎不起作用。我也尝试了 AutoLayout,但没有奏效。我不知道还能做什么。任何人都对如何解决这个问题有任何建议或想法。

编辑:我尝试过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;
        }
    }

【问题讨论】:

    标签: iphone ios objective-c uitableview uinavigationcontroller


    【解决方案1】:

    在与标签使用关联的 UITableViewController 的 viewDidLoad 方法中(假设它是通过调用 tabBarController 加载的)

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

    【讨论】:

    • 在我的 UITableViewController 的 viewDidLoad 中使用您的代码,它不起作用,并且还使 tabBar 变成了半透明的黑色/灰色。
    • 我必须在 TabBarViewController 的 viewDidLoad 中设置它。这解决了布局/边缘问题,但现在我的导航栏变暗了。
    • 制作self.extendedLayoutIncludesOpaqueBars = YES;
    • 它仍然使导航栏变暗,我可以添加动画方式。加载链接:i.imgur.com/mriSAly.png 完整链接:i.imgur.com/lKmc3Vh.png
    【解决方案2】:

    我用以下方法解决了这个问题:

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

    【讨论】:

    • 你把这个放在哪里了? AppDelegate?还是在 TabBarViewController 的 View 中加载了?
    • 我把它设置成 ViewDidLoad
    • 我把它放在我的 TabBarViewController 的视图中确实加载并且它正在工作,有点。现在导航栏变成了深色,模拟器在一直推到新的视图控制器之前闪烁了一下。有什么解决办法吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-02-24
    • 2020-03-15
    • 2012-10-21
    • 2015-07-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多