加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

osx – 获取“此应用程序正在修改自动布局引擎”错误?

发布时间:2020-12-14 06:20:37 所属栏目:百科 来源:网络整理
导读:我遇到这个错误很多在我的OS X使用swift: “This application is modifying the autolayout engine from a background thread,which can lead to engine corruption and weird crashes. This will cause an exception in a future release.” 我有一个我的N
我遇到这个错误很多在我的OS X使用swift:

“This application is modifying the autolayout engine from a background thread,which can lead to engine corruption and weird crashes. This will cause an exception in a future release.”

我有一个我的NSWindow,我正在交换窗口的contentView的视图。我得到的错误,当我尝试,并在窗口上做一个NSApp.beginSheet,或当我添加一个子视图到窗口。试图禁用自动调整大小的东西,我没有什么使用自动布局。有什么想法吗?

有时它很好,没有发生,其他时候,它完全打破了我的UI,没有负载

好吧 – 找到答案。它需要放置在一个不同的线程,允许UI更新一旦执行线程函数完成:

Swift版本

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

Objective-C版本

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读