我使用segue从ViewController B
过渡到ViewController A
,同时使用segue将数据从ViewController B
传递到ViewController A
。我已经构建了我的代码,其中用户将点击backbutton
并使用SCLAlertView cocoapods
执行alert controller
。它会提示
在它进入下一个ViewController
之前,但当我运行它时,segue会自动执行,而不会先检查条件,也不会执行alert controller
。我的代码下面是你的reference.Hope,你可以在这方面帮助我,因为我在swift是新手,我有我的研究,但似乎我看不到适用于我的问题的解决方案。谢谢。
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "showVCA" {
if let vc_A = segue.destination as? ViewControllerA {
vc_A.validPincode = validPincode
vc_A.participants = participants
vc_A.event = event
}
}
}
@IBAction func backbutton(_ sender: UIButton) {
let alert = SCLAlertView(appearance: confirmationAppearance)
_ = alert.addButton("Leave", action: {
self.dismiss(animated: true, completion: nil)
self.performSegue(withIdentifier: "showVCA", sender: sender)
})
_ = alert.addButton("Stay", action: { })
_ = alert.showError("Confirmation", subTitle: "Are you sure you want to leave this page?")
}
发布于 2018-10-22 02:45:27
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "showVCA" {
if let vc_A = segue.destination as? ViewControllerA {
vc_A.validPincode = validPincode
vc_A.participants = participants
vc_A.event = event
}
}
}
@IBAction func backbutton(_ sender: UIButton) {
let alert = SCLAlertView(appearance: confirmationAppearance)
_ = alert.addButton("Leave", action: {
self.dismiss(animated: true, completion: nil)
if validation() {
self.performSegue(withIdentifier: "showVCA", sender: sender)
}
})
_ = alert.addButton("Stay", action: { })
_ = alert.showError("Confirmation", subTitle: "Are you sure you want to leave this page?")
}
func validation() -> Bool {
// add validation logic here
return false
}
发布于 2018-10-22 02:58:00
您的backbutton()
函数似乎没有显示警报控制器(通过调用SCLAlertView
的众多showXXX()
函数中的一个),因此不会显示任何内容。是否有可能您的按钮连接到视图控制器的出口,而不是操作?
https://stackoverflow.com/questions/52921717
复制相似问题