我正在开发应用程序,我使用自定义表视图单元格来显示数据。当我的应用程序运行时,它会发出此警告。
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
我添加了一些断点,并查看了一下,这一次是什么时候。在这一点上,它来了(我调用自定义表视图单元格的时间。)
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
AirportTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"identifier"];//in here it comes
ac = [detailArray objectAtIndex:indexPath.row];
cell.airportname.text = ac.airPort;
return cell;
}
我试过这个
dispatch_async(dispatch_get_main_queue(), ^{
// code here
});
但我不知道如何正确使用它。有什么办法可以避免这种情况吗?请回答。thanx
cellForRowAtIndexPath:不应从后台线程调用。您可能正在从后台线程调用reloadData:或类似的东西,这是非常不健康的。