gpt4 book ai didi

xcode - 使用 InstantiateViewController 传递数据

转载 作者:行者123 更新时间:2023-12-02 15:07:01 25 4
gpt4 key购买 nike

我有这段代码,但是我没有在第二个 View Controller 中接收数据...我在这里做错了什么?

        let storyboard = UIStoryboard(name: "PostSubmit", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "PostSubmitVC") as! PostSubmitViewController {
let nc = UINavigationController(rootViewController: vc)
vc.filteredResult = filteredResult
}
self.present(nc, animated: false, completion: nil)

最佳答案

问题可能是您在 block 内设置了错误的 Controller nc 值,并且在该 block 之外不可用。

 let vc = storyboard.instantiateViewController(withIdentifier: "PostSubmitVC") as! PostSubmitViewController 
let nc = UINavigationController(rootViewController: vc)
vc.filteredResult = filteredResult
self.present(nc, animated: false, completion: nil)

关于xcode - 使用 InstantiateViewController 传递数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42665110/

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