Dismiss UIAlertView after 5 Seconds Swift

后端 未结 10 1786
悲哀的现实
悲哀的现实 2020-12-22 20:31

I\'ve created a UIAlertView that contains a UIActivityIndicator. Everything works great, but I\'d also like the UIAlertView to disappear after 5 seconds.

Ho

10条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-22 21:02

    I'm not an expert but this works for me and I guess is easier

    let alert = UIAlertController(title: "", message: "YOUR MESSAGE", preferredStyle: .alert)
    present(alert, animated: true) {
       sleep(5)
       alert.dismiss(animated: true)
    }
    

提交回复
热议问题