ios - 条形项按钮在运行时不显示,但在设计时在模态视图中可见

标签 ios swift swift3 interface-builder xcode8

我一直在尝试不同的事情并四处寻找了一段时间,但没有找到问题的答案。也许我在做一些根本性的错误。

示例应用程序包括:

  • 第一个 View Controller 使用 segue 显示第二个 View Controller 。这很好用。

  • 第二个 View Controller ,我在其中以编程方式模拟了第三个 View 的显示,其中包含我想要显示的栏项按钮(名为“完成”)。

第三个 View Controller 中的条形项按钮在运行时不显示,但在设计时在 IntefaceBuidler 中显示。

第三个 View Controller 需要以模态显示。

显示此栏项按钮我做错了什么?

A sample project illustrating the problem is available here.

下面是设计时栏项按钮的屏幕截图:

enter image description here

下面是设计时未显示的栏项按钮的屏幕截图:

enter image description here

附言: 请忽略“Interface Builder 文件中的未知类 ThirdViewController”,因为 ThirdViewController 在运行时显示正常。此外, View 中间的“完成”按钮工作正常。

最佳答案

SecondViewController 中,您需要将第三个插入导航 Controller 堆栈,如下所示:

self.navigationController?.pushViewController(thirdViewController, animated: true)

您当前将其呈现为模态。此外,您还不必要地向 Storyboard添加了第二个 UINavigationController(用于第三个 View Controller )

如果你想呈现一个模式,那么你需要将 Controller 嵌入到导航 Controller 中:

let navController = UINavigationController(rootViewController: thirdViewController)
self.present(navController, animated: false)

如果您希望将其保留在 Storyboard 中,则需要为 UINavigationController 提供一个标识符,并在您的函数中填充它。

关于ios - 条形项按钮在运行时不显示,但在设计时在模态视图中可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43458140/

相关文章:

ios - 在不让光标移动到末尾的情况下格式化 UITextField 文本

ios - 寻找每帧更新实例属性的方法

ios - Swift 中的逻辑问题

swift - 在初始化闭包中访问 "self"

ios - 将 AVPlayerViewController 放在 UIView 中

ios - 更改 UICollectionView 数据源

ios - 如何制作功能正常的动画按钮?

ios - 当我们在 NSUserDefaults 中保存时,从核心数据和应用程序中获取 “<NULL>” 数据会崩溃吗?

ios - 我缺少有关 NSURLSessionConfiguration.HTTPMaximumConnectionsPerHost 的内容吗?

ios - 无法删除 UIButtons 和标签。