gpt4 book ai didi

ios - PageMenu pod 呈现 Modal segue 而不是 Push segue

转载 作者:行者123 更新时间:2023-12-01 19:53:05 24 4
gpt4 key购买 nike

This question relates to:


  • SWIFT: Push segue is resulting in a modal segue instead
  • 'Show' segue in Xcode 6 presents the viewcontroller as a modal in iOS 7

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

    这是我的 Storyboard的外观:

    enter image description here
    viewController有一个 segmentControl 控制两个 viewController。我现在想转至 DetailViewController,但它显示为隐藏 tabBar 和导航栏的模态转场。

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

    编辑:

    在测试了 pod 提供的演示后,我能够概述我正在努力解决的问题。我已经实现了几乎相同的相同方法。唯一的区别是我的方法 PageMenu不像演示那样使用 nib 文件。

    在我的 tableView 委托(delegate)中,我试图将配方数据传递给 DetailView .这就是我的 prepareForSegue 选择 看起来:
    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]

    }
    }

    这是演示的 选择 :
    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正如他们在演示中所做的那样,您几乎已准备就绪。

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

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

    更改代码以实例化 DetailVC 并将其推送到父导航 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)
    }

    }

    关于ios - PageMenu pod 呈现 Modal segue 而不是 Push segue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44637086/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com