【发布时间】:2017-06-19 18:01:08
【问题描述】:
这个问题涉及到:
我知道这个问题可能与其他问题非常相似。但我一直无法使用某些答案来解决我的问题。
这是我的故事板的外观:
viewController 有一个段控制,它控制两个视图控制器。我现在想转至 DetailViewController,但它显示为隐藏 tabBar 和导航栏的模态转场。
我已经尝试删除并重新创建 segue,因为答案中的一些建议但它没有解决任何问题。有什么人可以建议或指导我吗?
编辑:
在测试了 pod 提供的演示后,我能够概述我正在努力解决的问题。我已经实现了几乎相同的相同方法。唯一的区别是我的 PageMenu 方法不像演示那样使用 nib 文件。
在我的 tableView 委托中,我试图将配方数据传递给 DetailView。这就是我的 prepareForSegue 和 didSelect 的外观:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
performSegue(withIdentifier: "detail", sender: recipe)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "detail" {
let vc = segue.destination as! DetailViewController
let indexPath = tableView.indexPathForSelectedRow!
vc.recipe = RecipeManager.shared.recipes[indexPath.row]
}
}
这是 demo 的 didSelect:
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let newVC : UIViewController = UIViewController()
newVC.view.backgroundColor = UIColor.white
newVC.title = "Favorites"
parentNavigationController!.pushViewController(newVC, animated: true)
}
在将它与演示进行比较时,我很难理解在哪里实施 parentNavigationController!.pushViewController(newVC, animated: true),我相信这会解决我的问题。
【问题讨论】:
-
你说的“viewController有一个segmentControl控制两个viewController”是什么意思?您是否使用它将一个或另一个表视图加载到容器视图中?
-
您是否尝试将嵌入在 UINavigationController 中的视图控制器推送到另一个 UINavigationController 上?
-
@DonMag 基本上我正在使用一个名为“PageMenu”的 pod,它使用 viewController 执行分段操作,您可以在其中滑动到不同的页面,就像您在 Instagram 上看到的那样。
-
@suhit 不确定您的意思。如您所见,我只有一个 UINavigationController。我要做的就是继续使用 DetailViewController。
-
@Chace - 好的...很可能,您的“PageMenu”窗格导致您的 segue 被放置在导航控制器堆栈的外部。您需要弄清楚视图层次结构是如何排列的,并确保与
DetailVC的转接正在完成来自ViewController而不是来自子VC 作为一部分“页面菜单”
标签: ios segue uistoryboardsegue