Swift:在 Eureka 表单中关闭 FormViewController

标签 swift eureka-forms

我对 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/

相关文章:

github - 在 Cartfile 中指定 Github 分支

swift - Eureka - DateRow 加载日期而不改变其当前值

ios - 当 applicationWillResignActive 时从 AppDelegate 暂停计时器

swift - 绑定(bind)到 2 个 UITextField 的计算中添加百分比

swift - 努力理解代码 - 它试图返回数字右侧的十进制数字 'n'

ios - 将远程图像加载到 Tableview 单元格中

ios - Swift 中的协议(protocol)声明 - Xcode 6 beta 5

ios - 如何更改 PushRow View Controller 的状态栏样式?

ios - Eureka 通过标签获取 SelectableSection

swift - Eureka表单不显示