且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

获取“此应用程序正在从后台线程修改自动布局引擎"错误?

更新时间:2022-12-09 11:19:20

它需要放置在不同的线程中,以便在线程函数执行完成后立即更新 UI:

It needs to be placed inside a different thread that allows the UI to update as soon as execution of thread function completes:

现代斯威夫特:

DispatchQueue.main.async {
    // Update UI
}

Swift 3 之前的旧版本 Swift.

Older versions of Swift, pre Swift 3.

dispatch_async(dispatch_get_main_queue(){
    // code here
})

目标-C:

dispatch_async(dispatch_get_main_queue(), ^{
    // code here
});