【发布时间】:2018-03-12 10:27:03
【问题描述】:
我有一个TabbarController,它是我的应用程序的入口点。所以我想将此TabbarController 转为ViewControllerA。我执行performSegue(with: "identifier")。我可以到达ViewControllerA,但是当我到达ViewControllerA 时没有NavigationBar
我尝试将ViewControllerA 嵌入到NavigationController 1st 中,所以故事板看起来像这样
TabbarController-> NavigationController -> ViewControllerA
通过这个,我可以到达 ViewControllerA。但是我的 prepareForSegue 方法有问题。因为我需要在 segue 中包含一个值,现在该值似乎不包含在内。
我在 prepareForSegue 中的代码如下所示:
if let VcA = segue.destination.navigationController?.topViewController as? ViewControllerA {
VcA.postId = sender as! Int
}else{
print("cant work")
}
我还尝试将 tabbarController 嵌入到 NavigationController,但在 Xcode-> Editor -> Embed 中,该选项被禁用。
所以我的问题是
如何从 TabbarController 切换到 ViewController 并且在目的地 NavigationBar 是可见的并且可以返回到上一个屏幕?
【问题讨论】:
-
当你嵌入 ViewControllerA.And 在 NavigationController 中,segue 之后你看到了什么。
-
“我执行
performSegue(with: "identifier")”在哪个文件中?它应该在ViewControllerA... -
在 TabbarController 兄弟 @AhmadF
-
@Nitish 我可以在 navigationController 中嵌入 ViewControllerA,我已经编辑了我的问题,我也可以转到 ViewControllerA,但我无法在 ViewControllerA 中获得 segue 的值
标签: ios swift uitabbarcontroller navigationcontroller