我正在使用 UIAlertController
来显示需要用户操作的用户警报。我想跳过用户操作并在一段时间后(比如 10 秒)让警报消失。这样做的最佳方法是什么?
最佳答案
在创建 UIAlertViewController 后试试这个
var dispatchTime: dispatch_time_t = dispatch_time(DISPATCH_TIME_NOW, Int64(10.0 * Double(NSEC_PER_SEC)))
dispatch_after(dispatchTime, dispatch_get_main_queue(), {
yourAlertViewController.dismissViewControllerAnimated(true, completion: nil)
})
关于swift - 我应该如何发出 swift 超时的警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30301549/