Xcode 9.2-标签值已更新,但未在模拟器中显示

时间:2018-07-22 20:19:39

标签: swift label delay xcode9

我无法使其正常运行!标签的文本未在模拟器中更新

请您告诉我如何解决此问题。

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"
        }
    }
}

0 个答案:

没有答案