首页 > 移动平台 > 详细

iOS之崩溃处理:This application is modifying the autolayout engine from a background thread

时间:2017-01-10 14:47:49      阅读:251      评论:0      收藏:0      [点我收藏+]

一、错误提示

今天在开发的时候遇到一个崩溃问题,“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.”如图所示

技术分享

二、错误写法

先来看一下代码的写法,如图所示:

技术分享

三、错误原因

后来观察代码后发现居然是在子线程里更新了UI导致的崩溃。在我们学习多线程的时候肯定会看到一句话:UI一定要在主线程中更新。这就是导致崩溃的主要原因,写代码GCD相关的代码一定切记更新UI的操作一定要放在主线程操作。

四、解决方法

既然知道了要在主线程更新UI,那么只需要在原来的代码里加上这段代码:

技术分享

 

 

iOS之崩溃处理:This application is modifying the autolayout engine from a background thread

原文:http://www.cnblogs.com/rglmuselily/p/6269071.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!