【发布时间】:2016-06-27 19:42:34
【问题描述】:
我尝试从present 的completion 参数执行一个任务,以便它仅在UIAlertController 关闭后执行所需的功能。但是,在警报中执行操作之前调用了该函数。如何等待执行该函数,直到采取行动?
let alert = UIAlertController(title: "Wild Card Played", message: "Choose your suit", preferredStyle : .alert);
for suit in suits {
alert.addAction(UIAlertAction(title: suit, style: .default, handler: crazyEightPlayed))
}
self.present(alert, animated: true, completion: cpuTurn) //Upon completion call the cpuTurn() function
【问题讨论】:
标签: ios xcode swift swift3 xcode8