小编Dan*_*ger的帖子

UIAlertController在关闭后保持重新出现

我已经写代码,出现报警时,在我的UITextFields的一个输入小于1050中输入满足这一点,但我后按"确定"它会立即重新出现时出现成功.

下面是viewDidLoad函数中的代码:

override func viewDidLoad(){
    super.viewDidLoad()
    alert = UIAlertController(title: "Error", message: "Please enter an exit width value greater than 1050", preferredStyle: UIAlertControllerStyle.Alert)
    let okay = UIAlertAction(title: "OK", style: UIAlertActionStyle.Destructive, handler: valueCalc)
    alert.addAction(okay)
}
Run Code Online (Sandbox Code Playgroud)

然后我有我的valueCalc功能(当点击按钮时调用):

@IBAction func valueCalc(sender: AnyObject){
    if(Int(mmText.text!)! < 1050){ //mmText is an UITextField
        self.presentViewController(alert, animated: true, completion: nil)
    }
}
Run Code Online (Sandbox Code Playgroud)

iphone alert ios swift uialertcontroller

0
推荐指数
1
解决办法
116
查看次数

标签 统计

alert ×1

ios ×1

iphone ×1

swift ×1

uialertcontroller ×1