7

我正在从具有底部标签栏的 tableview 以编程方式构建视图。I would like this bottom bar to disappear when a table cell is selected. 我可以这样做:

self.tabBarController.tabBar.hidden = YES;

但是视图的大小保持不变,就好像标签栏仍然存在一样。我看到,如果视图是在情节提要上构建的,并且通过设置复选标记“在推送时隐藏底部栏”,视图会调整大小以占据标签栏留下的空闲空间。我怎样才能以编程方式做到这一点?

4

2 回答 2

22
self.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:self.anotherViewController animated:animated];

以及您推动的特定视图控制器。使用此代码

    TheViewController* theController = [[TheViewController alloc] initWithNibName:@"TheViewController" bundle:nil];
    theController.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:theController animated:YES];
    [theController release];

现在标签栏将被隐藏并自动显示。享受时间:)

于 2012-05-20T13:16:56.150 回答
0

使用Swift

let viewController = CustomViewController()
viewController.hidesBottomBarWhenPushed = true

self.navigationController?.pushViewController(viewController, animated: true)
于 2021-12-13T22:07:49.733 回答