【发布时间】:2019-05-11 22:12:43
【问题描述】:
我正在开发一个包含多个嵌套 UIViewController 的应用程序。我有两个视图,一个是带有 uibarbuttonitem 的根视图控制器,它连接到另一个 UIViewController。
被设置为不接受的 UIViewController 和 UIButtons 或 UIBarButtonItems,我似乎无法为其设置标题。
我需要在 UINavigationBar 中放置一个标题和其他 UIElements 但似乎没有任何效果,我在网上没有找到任何解决方案。
UINavigationBar 甚至没有出现在视图的层次结构中。
感谢您的合作。
【问题讨论】:
-
@vacawama 我已经编辑了帖子。请再次检查。
-
尝试先添加一个 UINavigationItem。
-
到目前为止你做了什么?你能告诉我们一些代码吗?
-
在视图控制器中设置
self.title = "whatever"inviewDidLoad以设置标题。设置右栏按钮,如下所示:self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Foo", style: .plain, target: self, action: #selector(handleRightBarButton))
标签: swift uibutton uinavigationbar uibarbuttonitem