gpt4 book ai didi

Swift:在 Eureka 表单中关闭 FormViewController

转载 作者:行者123 更新时间:2023-11-30 10:34:49 26 4
gpt4 key购买 nike

我对 Swift 的 Eureka 表单(顺便说一句,很棒的库)相当陌生 - 但我在弄清楚如何关闭通过 show segue 呈现的 FormViewController 时遇到了麻烦。

我在 FormViewController 中有一个按钮 Row,它会触发 POST,然后调用委托(delegate)方法以从呈现的 View Controller 中关闭 FormViewController。此委托(delegate)方法正常触发,但 FormViewController 不会被关闭。

我查看了文档并进行了一些搜索,但我似乎找不到正确的信息。这是 FormViewController 在应该被解除后“卡住”的图像:https://i.imgur.com/zreGcVS.png

呈现 View Controller 中的 segue 和 delegate 方法:

//MARK: -Navigation

@IBAction func addButtonTapped(_ sender: Any) {
self.performSegue(withIdentifier: "addNewBusiness", sender: nil)
}

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "addNewBusiness" {
let destinationVC = segue.destination as! NewBusinessController
destinationVC.delegate = self
}
}

func businessAdded(data : JSON) {
self.dismiss(animated: true, completion: nil) //Not working
self.refresh(sender: self) //Working
let text = data["message"].stringValue //Working
print("My Businesses Controller: response JSON value is: \(text)") //Working
self.alertDisplayer.showTopMessage(text: text) //Working
self.soundPlayer.playSound(tone: "success") //Working
}

最佳答案

当关闭 ViewController 时,您应该使用关闭函数,而不是 segue。例如:

self.dismiss(animated: true, completion: nil)

如果它已被推送到 UINavigationController 中,那么您应该弹出它:

self.navigationController?.popViewController(animated: true)

关于Swift:在 Eureka 表单中关闭 FormViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58280886/

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