gpt4 book ai didi

swift - 首先呈现 View Controller ,然后推送 subview Controller

转载 作者:行者123 更新时间:2023-11-28 14:38:17 27 4
gpt4 key购买 nike

是否有技巧可以将之前以模态方式呈现的父 vc 推送到 subview Controller ?

我正在使用的呈现 parent 的方法:

    let parentVC = ParentController()
self.present(parentVC, animated: true, completion: nil)

然后推送到不起作用的子 Controller 的方法:

    let childVC = childController()
navigationController?.pushViewController(childVC, animated: true)

最佳答案

Is there a trick to push to child view controllers from a parent vc that previously has been presented modally?

如果你模态地呈现一个vc并且你想要这个vc推送一个child vc,你必须呈现vc 嵌入到 UINavigationController 中。

    let parentVC = ParentController()
self.present(parentVC, animated: true, completion: nil)

成为

    let parentVC = ParentController()
let parentNav = UINavigationController(rootViewController: parentVC)
self.present(parentNav, animated: true, completion: nil)

然后你可以在parentVC中做:

    let childVC = childController()
navigationController?.pushViewController(childVC, animated: true)

关于swift - 首先呈现 View Controller ,然后推送 subview Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50724602/

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