APP崩溃提示:This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes.

崩溃输出日志
2017-08-29 14:53:47.332368+0800 HuiDaiKe[2373:1135604] This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes.
 Stack:(
    0   CoreFoundation                      0x0000000188e42ff8 <redacted> + 148
    1   libobjc.A.dylib                     0x00000001878a4538 objc_exception_throw + 56
    2   CoreFoundation                      0x0000000188e42f28 <redacted> + 0
    3   Foundation                          0x0000000189a35378 <redacted> + 128
    4   Foundation                          0x000000018987da38 <redacted> + 36
    5   UIKit                               0x000000018ef703b0 <redacted> + 816
    6   UIKit                               0x000000018ef7c2ac <redacted> + 1740
    7   UIKit                               0x000000018f2a57f0 <redacted> + 88
    8   UIKit                               0x000000018efd9b04 <redacted> + 376
    9   UIKit                               0x000000018f049840 <redacted> + 232
    10  UIKit                               0x000000018f0495b8 <redacted> + 244
    11  UIKit                               0x000000018f0543cc <redacted> + 932
    12  UIKit                               0x000000018f053eec <redacted> + 184
    13  UIKit                               0x000000018f053914 <redacted> + 1728
    14  MJRefresh                           0x00000001013c72bc -[UITableView(MJRefresh) mj_reloadData] + 40
    15  HuiDaiKe                            0x000000010013e440 _TFC8HuiDaiKe40CustomersAddressBookImportViewControllerP33_17FF30CE5B34E964041849EE3753856C13setDataSourcefGSaCS_19cwsAddressBookModel_T_ + 2728
    16  HuiDaiKe                            0x000000010013d968 _TFFC8HuiDaiKe40CustomersAddressBookImportViewControllerP33_17FF30CE5B34E964041849EE3753856C11prepareDataFT_T_U_FTOCS_14cwsAddressBook4typeGSaCS_19cwsAddressBookModel__T_ + 992
    17  HuiDaiKe                            0x00000001001c9cc0 _TFFC8HuiDaiKe14cwsAddressBook3getFT4backFTOS0_4typeGSaCS_19cwsAddressBookModel__T__T_U_FTS1_GSaS2___T_ + 252
    18  HuiDaiKe                            0x00000001001ca5c8 _TFFFC8HuiDaiKe14cwsAddressBookP33_FC9266F7BF731B8D62B76C7FA41D90D413check_iOS_9_0FT4backFTOS0_4typeGSaCS_19cwsAddressBookModel__T__T_U0_FTSbGSqPs5Error___T_U_FTSbGSaS2___T_ + 96
    19  HuiDaiKe                            0x00000001001caa04 _TFC8HuiDaiKe14cwsAddressBookP33_FC9266F7BF731B8D62B76C7FA41D90D411get_iOS_9_0fT4backFTSbGSaCS_19cwsAddressBookModel__T__T_ + 828
    20  HuiDaiKe                            0x00000001001ca544 _TFFC8HuiDaiKe14cwsAddressBookP33_FC9266F7BF731B8D62B76C7FA41D90D413check_iOS_9_0FT4backFTOS0_4typeGSaCS_19cwsAddressBookModel__T__T_U0_FTSbGSqPs5Error___T_ + 220
    21  HuiDaiKe                            0x00000001001ca6bc _TTRXFo_dSboGSqPs5Error____XFdCb_dSbdGSqCSo7NSError___ + 132
    22  ContactsFoundation                  0x0000000191862748 <redacted> + 288
    23  ContactsFoundation                  0x000000019186d680 <redacted> + 600
    24  Contacts                            0x00000001918c814c <redacted> + 72
    25  libdispatch.dylib                   0x0000000187cfa9e0 <redacted> + 24
    26  libdispatch.dylib                   0x0000000187cfa9a0 <redacted> + 16
    27  libdispatch.dylib                   0x0000000187d090d4 <redacted> + 644
    28  libdispatch.dylib                   0x0000000187d0aa50 <redacted> + 540
    29  libdispatch.dylib                   0x0000000187d0a7d0 <redacted> + 124
    30  libsystem_pthread.dylib             0x0000000187f03100 _pthread_wqthread + 1096
    31  libsystem_pthread.dylib             0x0000000187f02cac start_wqthread + 4
)
崩溃原因

在子线程中更新UI导致主线程的视图布局出错

解决方法

把更新UI的操作放在主线程中执行

swift示例
DispatchQueue.main.async {
   self.mainTableview.reloadData()
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,192评论 4 61
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 172,866评论 25 708
  • 今天在写程序的时候,使用Xcode 运行工程时报出下面的错误错信息,我还以为是什么呢,好久没遇到过这样的错误了。 ...
    景彧阅读 25,179评论 10 20
  • 前两年刚毕业晋升为业务经理带领团队(销售型团队,从门店经理到营业副总),那会认为团队里的人就是自己的孩子,为了她们...
    海豚湾乐园阅读 307评论 3 4
  • 2016年12月22日我注册了简书,2017年1月24日发表的第一篇文章,昨天也就是2月7日我写的第九篇文章被专题...
    安妮Anne666阅读 978评论 12 22