Swift:以Eureka格式解散FormViewController

问题描述 投票:0回答:1

我对Swift的Eureka表单来说是个新手(顺便说一句,它是一个很棒的库-但是我在解决如何关闭通过show segue呈现的FormViewController时遇到了麻烦。

我在FormViewController中有一个按钮Row,它将触发POST,然后调用委托方法从当前的视图控制器中退出FormViewController。该委托方法会触发OK,但不会关闭FormViewController。

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

呈现视图控制器中的segue和委托方法:

//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
}
swift eureka-forms
1个回答
0
投票

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

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

如果已将其推送到UINavigationController中,则应该将其弹出:

self.navigationController?.popViewController(animated: true)
© www.soinside.com 2019 - 2024. All rights reserved.