首页 > 代码库 > 只能在主线程更改界面

只能在主线程更改界面

问题:

在主线程之外的线程更改界面,会报错: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.

解决方法:

把更改界面的语句写在这里面:

dispatch_async(dispatch_get_main_queue(), {

   // code here

})

只能在主线程更改界面