xcode 如何以编程方式设置“推送时隐藏底栏”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10673710/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 00:22:22  来源:igfitidea点击:

How to set programmatically "Hides bottom bar on push"?

iphonexcodeios5

提问by Malagasy Desi

I am building a view programmatically from a tableview which has a bottom tab bar. I would like this bottom bar to disappear when a table cell is selected. I can do that using:

我正在从具有底部选项卡栏的 tableview 以编程方式构建视图。I would like this bottom bar to disappear when a table cell is selected. 我可以使用:

self.tabBarController.tabBar.hidden = YES;

but the size of the view remains as if the tabbar was still there. I see that if the view is built on the storyboard and by setting the checkmark "Hides bottom bar on push", the view resizes to occupy the space left free by the tabbar. How can I do that programmatically?

但是视图的大小仍然就像标签栏仍然存在一样。我看到如果视图建立在故事板上并通过设置复选标记“在推送时隐藏底部栏”,视图会调整大小以占用标签栏留下的空间。我怎样才能以编程方式做到这一点?

回答by Saad

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

and for a specific view controller which your pushing. use this code

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

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

now the tabbar will be hidden and shown autometically. enjoy the time :)

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