获得一个"此应用程序修改自动布局引擎"错误? [英] Getting a "This application is modifying the autolayout engine" error?

查看:127
本文介绍了获得一个"此应用程序修改自动布局引擎"错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用SWIFT已经遇到这个错误很多我的OS X:该应用程序正在修改从后台线程,这可能会导致发动机损坏和怪异的崩溃自动布局引擎这将在以后的版本会导致异常。

Been encountering this error a lot in my OS X using 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,我在欣赏到窗口的内容查看交换。我得到的错误,当我尝试做一个NSApp.beginSheet在窗口上,或者当我添加一个子视图到窗口。尝试禁用自动调整大小的东西,使用自动布局我没有什么。有什么想法?

I have a my NSWindow and I'm swapping in views to the contentView of the window. I get the error when I try and do a NSApp.beginSheet on the window, or when I add a subview to the window. Tried disabling autoresize stuff, and I don't have anything using auto layout. Any thoughts?

有时,它的罚款,并没有任何反应,其他时候它完全打破了我的用户界面并没有什么负载

Sometimes it's fine and nothing happens, other times it totally breaks my UI and nothing loads

推荐答案

好吧 - 找到了答案。它需要被放置在不同的线程,使UI更新里面的:

Okay - found the answer. It needs to be placed inside a different thread that allows the UI to update:

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

的Objective-C版本

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

这篇关于获得一个"此应用程序修改自动布局引擎"错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆