【发布时间】:2016-04-06 12:18:18
【问题描述】:
我想在我的警报控制器中倒计时 3 秒。不知道该怎么做。我可以让警报在 3 秒内消失,只是倒计时不见了。
//simple alert dialog
let alertController = UIAlertController(title: "Workflow successful", message: "Modified reminder's priority or list.", preferredStyle: .Alert)
var secs = 3
let defaultAction = UIAlertAction(title: "Dismiss in " + secs, style: .Default, handler: nil)
alertController.addAction(defaultAction)
dispatch_async(dispatch_get_main_queue()) {
//self.presentViewController(alertController, animated: true, completion: nil)
self.showViewController(alertController, sender: self)
}
let delayTime = dispatch_time(DISPATCH_TIME_NOW,
Int64(secs * Double(NSEC_PER_SEC)))
dispatch_after(delayTime, dispatch_get_main_queue()) {
alertController.dismissViewControllerAnimated(true, completion: nil)
}
【问题讨论】:
标签: swift delay uialertcontroller