0

我正在尝试使用 alertview 将错误打印给用户。这是我的代码:::

if error != nil{
 let DisplayAlert = UIAlertController(title: "Error!!", message: error?.description, preferredStyle: .Alert)
 DisplayAlert.addAction(UIAlertAction(title: "OK", style: .Default, handler: nil))
}

当我运行代码时,我在控制台中看到以下内容,并且没有看到向用户显示任何警报。

“在解除分配时尝试加载视图控制器的视图是不允许的,并且可能导致未定义的行为”

我应该怎么做才能解决这个问题。?请帮忙。谢谢 !!!

4

1 回答 1

1

看起来您忘记显示警报了

if error != nil{
    let DisplayAlert = UIAlertController(title: "Error!!", message: error?.description, preferredStyle: .Alert)
     DisplayAlert.addAction(UIAlertAction(title: "OK", style: .Default, handler: nil))
    self.presentViewController(DisplayAlert, animated: true, completion: nil)
}
于 2016-08-09T17:55:22.537 回答