gpt4 book ai didi

ios - 回到 UIViewController 不会触发 segue

转载 作者:行者123 更新时间:2023-11-28 11:42:29 29 4
gpt4 key购买 nike

我有 Controller B,它使用委托(delegate)模式将数据发送回 Controller A,但由于某种原因我的 segue 没有触发。

是否有什么东西阻止我的 segue 被触发?我将如何解决这个问题?

Controller B - 模态呈现

@IBAction func addButton(_ sender: Any) {
delegate?.select(sID: selectedID)
dismiss(animated: true, completion: nil)
}

Controller A

func select(sID: String) {
performSegue(withIdentifier: "editSegue", sender: self);
}

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "editSegue" {
if let destinationVC = segue.destination as? NewController {
destinationVC.selectedQueryID = selectedQueryID;
print(“test”);
}
}
if segue.identifier == "selectSegue" {
if let destinationVC = segue.destination as? ControllerB {
destinationVC.queryID = selectedQueryID;
destinationVC.delegate = self;
}
}
}

Controller C - 模态呈现(不呈现自身)

最佳答案

在B View Controller 中,dismiss完成时触发

@IBAction func addButton(_ sender: Any) {

dismiss(animated: true, completion: {
delegate?.select(sID: selectedID)
}
}

还要确保您以模态方式呈现 B viewcontroller。

关于ios - 回到 UIViewController 不会触发 segue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53374390/

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