我无法使其正常运行!标签的文本未在模拟器中更新
请您告诉我如何解决此问题。
P.S。再单击一次按钮后,将显示标签文本
@IBAction func doneButtonClicked(_sender : UIButton) {
if textField.text == "" {
// do nothing
} else {
textField.text = ""
mainTaskLabel.text = ""
iwillLabel.text = "I'VE DONE IT"
todayLabel.text = "GREAT!"
let delayInSeconds = 2.0 // 2 seconds
// do delay for 2 seconds. it change the value but not updating labels
DispatchQueue.main.asyncAfter(deadline: .now() + delayInSeconds) {
self.mainTaskLabel.text = "... DO NOTHING ..."
self.iwillLabel.text = "I WILL"
self.todayLabel.text = "TODAY"
}
}
}