gpt4 book ai didi

ios - 如何使用 Swift 从警报中的按钮单击返回 bool

转载 作者:行者123 更新时间:2023-11-30 12:37:53 25 4
gpt4 key购买 nike

 override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject!) -> Bool {
let appearance = SCLAlertView.SCLAppearance(
showCloseButton: false,
showCircularIcon: false
)
let alertView = SCLAlertView(appearance: appearance)
alertView.addButton("First") {
return true
}
alertView.addButton("Second") {
return false
}

alertView.showSuccess("warning", subTitle: "something")


}

上面的代码需要 return true/false在最后一个花括号之前,但如果我这样做,我就会失去返回按钮。

有什么办法可以存档吗?

我使用SCLAlertView对于我的警报(如果有人知道如何使用 uialert 进行操作,我希望看到它)

提前致谢。

最佳答案

为了添加到第一个注释,我在标题单元格中使用了 UISwitch,并在类的顶部声明了 bool 变量

@IBAction func `switchAction`(_ sender: UISwitch) {
selected = sender.isOn
if selected == false {
//do you stuff here change false to true if you need it that way
}
}

然后在这个方法中设置如下

override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
var enable: Bool = false
if selected == false {
enable = true
} else {
enable = false
}

return enable
}

关于ios - 如何使用 Swift 从警报中的按钮单击返回 bool,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42629829/

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