This application is modifying the autolayout engine from a background thread, which can lead to engi
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了This application is modifying the autolayout engine from a background thread, which can lead to engi相关的知识,希望对你有一定的参考价值。
一,经历
<1> 使用SDWebImage下载 成功图片后,将图片设置给 self.imageView.image,提示如题所示的错误提示.
<2>第一反应就是慢慢注释掉代码进行调试,结果发现是在成功的回调中出事了,代码如下:
1 - (void)setupDownloadImage{ 2 NSURL *url = [NSURL URLWithString:@"http://i4.pdim.gs/dmfd/200_200_100/t01f117f76fc58c257c.gif"]; 3 4 SDWebImageDownloader *downloader = [SDWebImageDownloader sharedDownloader]; 5 [downloader downloadImageWithURL:url options:0 progress:nil completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) { 6 if (data != nil && image != nil) { 7 UIImage *image = [UIImage sd_animatedGIFWithData:data]; 8 self.imageView.image = image; 9 }else { 10 UIImage *image = [UIImage imageNamed:@"12345"]; 11 self.imageView.image = image; 12 } 13 }]; 14 }
<3>初步怀疑是sdwebimage 设置gift 图片失败,就在成功的回调中使用了一张本地的图片,依旧报错.
<4>仔细研究了提示,发现了关键词"a background thread",才知道是 sdwebimage 的后台线程在执行一些操作,仔细想了想才知道是更新 UI的操作必须在主线程中执行.
二,总结
<1>一定要注意子线程中对更新 UI 的使用.
以上是关于This application is modifying the autolayout engine from a background thread, which can lead to engi的主要内容,如果未能解决你的问题,请参考以下文章
iOS之崩溃处理:This application is modifying the autolayout engine from a background thread
Connection is read-only. Queries leading to data modification are not allowed 错误原因
webstorm报错TypeError: this.cliEngine is not a constructor
Connection is read-only. Queries leading to data modification are not allowed
Bisecting GlcNAc is a general suppressor of terminal modification of N-glycan (解读人:王茹凯)
后台打印:This application is modifying the autolayout engin from a background thread,which can lead to e