美文网首页
Main Thread Checker: UI API call

Main Thread Checker: UI API call

作者: _假装在上海 | 来源:发表于2017-12-20 18:55 被阅读0次

Xcode9 ,iOS11,会出现这个问题。原因就是不在主线程中修改了UI导致crash

有2种解决方案

解决方案1:
Edit Scheme里面取消勾选 Main Thread Checker

image

解决方案2:
把修改UI的代码放回主线程。

dispatch_async(dispatch_get_main_queue(), ^{
        // 把addSubview,insertSubview,放到这里
    });

相关文章

网友评论

      本文标题:Main Thread Checker: UI API call

      本文链接:https://www.haomeiwen.com/subject/ptknwxtx.html