我有时打电话给UIAlert
正在尝试加载视图控制器的视图
不允许取消分配,可能导致未定义的行为
()
code used:
func alert (dictKey: String){
print(dictKey)
let alertController = UIAlertController(title: nil, message: promptsArr[dictKey], preferredStyle: .Alert )
let OKAction = UIAlertAction(title: "OK", style: .Default) { (action) in
}
alertController.addAction(OKAction)
if self.presentedViewController == nil {
delay(1.0){
self.presentViewController(alertController, animated: true, completion: nil)
}
} else {
self.presentedViewController!
}
最佳答案
删除delay()
把逻辑放进去:
(如果存在警报,则不需要创建警报)
func alert (dictKey: String){
if self.presentedViewController == nil {
let alertController = UIAlertController(
title: nil,
message: promptsArr[dictKey],
preferredStyle: .Alert )
let OKAction = UIAlertAction(title: "OK", style: .Default) {
(action) in
}
alertController.addAction(OKAction)
self.presentViewController(
alertController,
animated: true,
completion: nil)
}
}
关于ios - 在Swift中调用UIAlertController:0x7ff211650140时发出警告,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33705748/