【问题标题】:Tabbar not displayed in certain UIViewController in navigation stack标签栏未显示在导航堆栈中的某些 UIViewController 中
【发布时间】:2013-01-07 12:31:58
【问题描述】:

我正在尝试制作一个基于导航的应用程序,在导航堆栈中包含三个 UIViewController。我有一个底栏 (UITabBar)。

我想在第一个UIViewController 被推入堆栈时隐藏标签栏,我想在第二个UIVIewController 被推入时显示标签栏。

这是我为此编写的代码。

首先UIVIewController

NotificationDetailsVC *obj = [[NotificationDetailsVC alloc] init];
obj.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:obj animated:YES];
[obj release];

第二次UIViewController我已经完成了:

NotificationBO *obj=[self.notificationsArray objectAtIndex:indexPath.row];
object.hidesBottomBarWhenPushed = NO;
[self.navigationController pushViewController:object animated:YES];
[object release];

现在的问题是,我可以为第一个 UIViewController 隐藏 UITabBar,但第二个它也被隐藏了。

我该如何解决这个问题?

【问题讨论】:

    标签: iphone ios uinavigationcontroller uitabbarcontroller


    【解决方案1】:

    而不是使用hidesBottomBarWhenPushed 方法。在ViewController 中尝试隐藏标签栏的代码,例如

    [self.tabBarController.tabBar setHidden:YES];
    

    对于显示标签栏

    [self.tabBarController.tabBar setHidden:NO];
    

    上面的可以工作,但问题是它会在viewController底部留下一个空白空间。要克服这个问题,请将frame 设置为您的tabbarController

    对于隐藏,设置

    [self.tabBarController.tabBar setFrame:CGRectMake(0, 480, 320, 50)]
    

    对于显示,设置

    [self.tabBarController.tabBar setFrame:CGRectMake(0, 430, 320, 50)]
    

    【讨论】:

    • 你知道 iPhone 5 吗?最好使用 self.view.frame.size.height 而不是 480。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-27
    • 1970-01-01
    • 2012-08-03
    • 1970-01-01
    • 1970-01-01
    • 2011-03-12
    相关资源
    最近更新 更多