iOS - 工具栏未显示

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

iOS - Toolbar not showing

iosstoryboardtoolbarviewcontrollersegue

提问by Mauricio Zambon

Using the storyboard I created a new screen for a second View controller and added a Toolbar at the bottom. But when the view is shown, the toolbar doesn't appear. I'm using Segue to change views.

我使用故事板为第二个视图控制器创建了一个新屏幕,并在底部添加了一个工具栏。但是当显示视图时,工具栏不会出现。我正在使用 Segue 来更改视图。

What could be wrong?

可能有什么问题?

回答by Fernando Madruga

If you're using a Navigation Controller, make sure to tick "Shows Toolbar" and add the buttons there, not on a standalone toolbar.

如果您使用的是导航控制器,请确保勾选“显示工具栏”并在那里添加按钮,而不是在独立工具栏上。

In order to show only on some, you'll need 2 different views, one that will hide it and another that won't and add the following to the respective view's viewWillAppear:

为了仅在某些视图上显示,您需要 2 个不同的视图,一个将隐藏它,另一个不会将以下内容添加到相应视图的 viewWillAppear:

    self.navigationController.toolbarHidden = YES;

(Set to YES to hide, NO to show)

(设置为 YES 隐藏,NO 显示)

You can play around with the Simulated Metrics on the Storyboard so as to visually simulate the run-time effect by setting Bottom Bar to either None or Toolbar instead of inferred, as appropriated.

您可以在 Storyboard 上使用 Simulated Metrics,以便通过将底部栏设置为 None 或 Toolbar 而不是推断来直观地模拟运行时效果(视情况而定)。

EDIT: Check thissample project I made.

编辑:检查我制作的这个示例项目。

回答by malhal

Select the Navigation Controller in the storyboard. Under Bar Visibility, check "Shows Toolbar".

在故事板中选择导航控制器。在栏可见性下,选中“显示工具栏”。

回答by slonkar

try this

尝试这个

self.navigationController.toolbarHidden=NO;

回答by user3317531

In the show the size inspector in the field autosizinf choose to bind to the top of the screen and remove the binding to the bottom of the screen.

在显示字段 autosizinf 中的大小检查器中,选择绑定到屏幕顶部并删除绑定到屏幕底部。