繁体   English   中英

PageMenu pod呈现Modal segue而不是Push segue

[英]PageMenu pod presents Modal segue instead of Push segue

这个问题涉及

我了解这个问题可能与其他问题非常相似。 但是我一直无法使用一些答案来解决我的问题。

这是我的故事板的外观:

在此处输入图片说明

viewController有一个segmentControl,它控制两个viewController。 我现在想选择到DetailViewController,但它显示为模式选择,它隐藏了tabBar和navigationBar。

我已经尝试删除并重新创建segue,因为答案中的某些建议已提出,但它无法解决任何问题。 有什么可以建议我或指导我的吗?

编辑:

在测试了Pod提供的演示之后,我可以概述自己所遇到的问题。 我已经实现了几乎相同的相同方法。 唯一的区别是,此PageMenu方法不像演示那样使用nib文件。

在我的tableView委托中,我试图将配方数据传递给DetailView 这是我的prepareForSeguedidSelect的样子:

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]

    }
}

这是演示的 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) ,我相信它将解决我的问题。

假设您像演示中一样实现了parentNavigationController ,那么您几乎已经parentNavigationController

删除现有的Segue-您将不会使用它。

给您的DetailViewController一个Storyboard ID-例如“ DetailVC”

更改代码以实例化DetailVC并将其推送到父级Nav Controller

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

    if let vc = self.storyboard?.instantiateViewController(withIdentifier: "DetailVC") as? DetailViewController {
        vc.recipe = RecipeManager.shared.recipes[indexPath.row]
        parentNavigationController!.pushViewController(vc, animated: true)
    }

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM