gpt4 book ai didi

ios - 在 UIAlertController 之后重新加载 View

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

我有一个带有电话号码字段的注册屏幕。如果用户输入的电话号码太短,我会显示一个 UIAlertController。在她解除警报后,用户无法再次发送她的电话号码,因为点击了发送按钮。有没有办法在解除警报以使按钮未被点击时重新加载 View ?谢谢

    func present_alert(title:String, content : String){
let myAlert = UIAlertController(title:title, message:content, preferredStyle:UIAlertControllerStyle.alert)
let okAction = UIAlertAction(title: "Ok", style: UIAlertActionStyle.default, handler:nil)
myAlert.addAction(okAction)
self.present(myAlert, animated:true)
}

最佳答案

单击按钮的主要原因是您禁用了您的按钮 sender.isEnabled = false,当再次出现警报时启用您的按钮,肯定可以 addyourbuttonName.isEnabled = true

如果您想清除当前的文本字段值,请使用 yourtextfield.text = ""

let alertController = UIAlertController(title: “Simple”, message: “Simple alertView demo with Cancel and Ok.”, preferredStyle: UIAlertControllerStyle.alert)

let okAction = UIAlertAction(title: “OK”, style: UIAlertActionStyle.default) { (result : UIAlertAction) -> Void in
print(“OK”)
yourtextfield.text = ""
yourtextfield.becomeFirstResponder()
addyourbuttonName.isEnabled = true
}


alertController.addAction(okAction)
self.present(alertController, animated: true, completion: nil)

关于ios - 在 UIAlertController 之后重新加载 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42251232/

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