您的位置:首页 > 移动开发

更换NSURLSession后 报错 This application is modifying the autolayout engine from a background thread, whi

2016-05-18 14:25 483 查看
更换NSURLSession后 报错 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. 然后balabala还有一堆栈或堆上的错误。

找了半天,最终结论是,刷新UI要回到主线程。由于是自己写的网络请求类,每个界面刷新UI不可能都加回到主线程。so

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
dispatch_async(dispatch_get_main_queue(), ^{

});
}


在请求下数据来后 就回到主线程。这样就解决啦
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  iOS