Lan*_*rit 5 user-interface updates swift
我试图让视图控制器在我处于循环中时更新,该循环调用一个执行大量标签更新的函数。但是在我完成循环之前不会更新屏幕。
有没有办法在继续之前强制更新 UI?类似于强制将数据写入磁盘。
按钮开始循环的代码是这样的:
        while (match.currentInnings == currentInnings)
        {
            playSingleBall()
            if (gameover == true)
            {
                return
            }
        }
在 playSingleBall 之后,我想在继续之前强制进行 UI 更新。
谢谢。
在调度队列中调用它:
斯威夫特3.x
DispatchQueue.main.async {
    updateYourUI()
}
斯威夫特2.x
dispatch_async(dispatch_get_main_queue()) {
   updateYourUI()       
}