xcode 隐藏底栏导航控制器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8040128/
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-14 22:21:05  来源:igfitidea点击:

Hide Bottom Bar Navigation Controller

iphoneobjective-ciosxcodeinterface-builder

提问by Baub

I want to hide the bottom toolbar on a certain screen in my application, and IB seems to have an option for that which seems to preview as working correctly, but when I build and test the application the bottom toolbar is still there.

我想在我的应用程序的某个屏幕上隐藏底部工具栏,IB 似乎有一个选项,它似乎可以正常工作,但是当我构建和测试应用程序时,底部工具栏仍然存在。

I know that I can use [self.navigationController setToolbarHidden:YES];but my question is not how to do it using code, but how to get this to work through Interface Builder.

我知道我可以使用,[self.navigationController setToolbarHidden:YES];但我的问题不是如何使用代码来做到这一点,而是如何通过 Interface Builder 让它工作。

enter image description here

在此处输入图片说明

Here is a screenshot of what I am talking about. See on the right how I have selected Bottom Bar: None - this removes the bottom bar as previewed to the left. If I set it to inferred (instead of None) the bottom bar shows in the IB preview.

这是我正在谈论的内容的屏幕截图。在右侧查看我如何选择底部栏:无 - 这将删除左侧预览的底部栏。如果我将其设置为推断(而不是无),则底部栏会显示在 IB 预览中。

How do I get this to work correctly?

我如何让它正常工作?

采纳答案by Ole Begemann

You can't set this in Interface Builder. If you notice the header of the section in IB where you can turn on/off these different bars, it says "simulated". These options are only there to help you visualize your UI in IB while designing it. They have absolutely no influence on the running app.

你不能在 Interface Builder 中设置它。如果您注意到 IB 中可以打开/关闭这些不同栏的部分的标题,它会显示“模拟”。这些选项仅用于帮助您在设计时在 IB 中可视化您的 UI。它们对正在运行的应用程序绝对没有影响。

回答by coolcool1994

I couldn't do it in storyboard when you just want to hide toolbar in one view controller. If you want to hide it for all, you need to go to the navigation controller, and set the values in the storyboard. But this makes all of your view controllers to hide the toolbars. If you want to hide it for one view controller use this in that view controller:

当您只想在一个视图控制器中隐藏工具栏时,我无法在故事板中做到这一点。如果要全部隐藏它,则需要转到导航控制器,并在故事板中设置值。但这会使您的所有视图控制器隐藏工具栏。如果您想为一个视图控制器隐藏它,请在该视图控制器中使用它:

-(void) viewWillAppear:(BOOL)animated
{
    [self.navigationController.toolbar setHidden: YES];
}

-(void) viewWillDisappear:(BOOL)animated
{
    [self.navigationController.toolbar setHidden: NO];
}

回答by Till

Enable "Hides Bottom Bar on Push" within the IB in case your ViewController is pushed onto a UINavigationController stack.

如果您的 ViewController 被推送到 UINavigationController 堆栈上,请在 IB 中启用“Hides Bottom Bar on Push”。

This should exactly do what you are asking for. As a bonus, the hiding and showing will be nicely animated by the system.

这应该完全符合您的要求。作为奖励,隐藏和显示将由系统很好地动画。