小编MJI*_*ICT的帖子

多个警报迅速叠加

现在我收到错误:警告:尝试在 CollectionViewController 上呈现 UIAlertController:0x7f9af9016200:0x7f9af750d620 已经呈现(空)

有没有办法快速堆叠警报?有我的代码,如果项目发布时间超过一天,它会显示警报。我尝试过两种方法但没有成功。

  1. 暂停 for 循环,直到我按是或否。
  2. 在彼此之上显示许多警报

任何解决方案如何管理做到这一点?

for p in json! {
     if self.checkDaysPassed(postDate: p["uploadedTime"] as! String) > 1 {
     print("more than one day passed, sell item?")

     let alert = UIAlertController(title: "Sell this item", message: "This item has been unused for a day", preferredStyle: .alert)
     alert.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
     alert.addAction(UIAlertAction(title: "Yes", style: .default){ (action) in
           print("pressed yes")
     })
     alert.addAction(UIAlertAction(title: "No", style: .cancel){ (action) in
          print("pressed no")
     })
     self.present(alert, animated: true)
    }
}
Run Code Online (Sandbox Code Playgroud)

alert swift uialertcontroller uialertaction

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

标签 统计

alert ×1

swift ×1

uialertaction ×1

uialertcontroller ×1