CRASH
是:
此应用程序正在从后台线程修改autolayout引擎,这可能导致引擎损坏和奇怪的崩溃。这将在将来的版本中引发异常。
很明显,问题是每次更改ui都必须在主线程上完成。理论上这可能有用
dispatch_async(dispatch_get_main_queue(), {
// code here
})
我的职能是:
- (void)requestInBlock:(NSString *)keyThumbnails withArrayQuantity:(NSMutableArray *)quantityArray andOriginalQuantity:(NSInteger)originalQuantity
{
int limit = 5;
NSMutableArray *arrayFive = [[NSMutableArray alloc] init];
NSInteger idQuantityOriginalCount = [quantityArray count];
for (NSInteger i = 0; i < MIN(limit, idQuantityOriginalCount); i ++) {
[arrayFive addObject:[quantityArray objectAtIndex:0]];
[quantityArray removeObjectAtIndex:0];
}
NSInteger idLimitArrayCount = [arrayFive count];
NSInteger __block countProductsRequestLimit = 0;
for (NSNumber *j in arrayFive) {
UIImageView * thumbnailImageView = [[UIImageView alloc] initWithFrame:CGRectMake(xposThumbnails, 0, ratio * 2, 47)];
[thumbnailsView addSubview:thumbnailImageView];
NSURL *imageUrl = [NSURL URLWithString:[NSString stringWithFormat:@"https://s3-us-west-2.amazonaws.com/xxxxxxxxxxxxxx/%@_%@.jpg",keyThumbnails,j]];
[Utils loadFromURL:imageUrl callback:^(UIImage *image) {
countProductsRequestLimit++;
countThumbnailsGlobal++;
[thumbnailImageView setImage:image];
[cutVideoScroll addSubview:thumbnailsView];
if (!image) {
NSMutableDictionary *collectInfoFailImage = [[NSMutableDictionary alloc] init];
[collectInfoFailImage setValue:thumbnailImageView forKey:@"image"];
[collectInfoFailImage setValue:imageUrl forKey:@"imageUrl"];
[thumbnailsWithError addObject:collectInfoFailImage];
collectInfoFailImage = nil;
}
if (countThumbnailsGlobal == originalQuantity) {
[arrayFive removeAllObjects];
[self performSelector:@selector(reloadThumbnailsWithError) withObject:nil afterDelay:3];
} else if (idLimitArrayCount == countProductsRequestLimit) {
[arrayFive removeAllObjects];
[self requestInBlock:keyThumbnails withArrayQuantity:quantityArray andOriginalQuantity:originalQuantity];
}
}];
xposThumbnails += (ratio * 2);
}
loadingTimeLine.layer.zPosition = -1;
lblloadingTimeLine.layer.zPosition = -1;
}
我认为错误发生在loadFromURL
。 ( 对此不太确定,因为在我进行测试的所有设备中,这种情况从未发生过,有人通知我并向我发送了错误日志 )
我的问题是:
[cutVideoScroll addSubview:thumbnailsView];
?更新:
我正在测试。
dispatch_async(dispatch_get_main_queue(), ^{
[thumbnailImageView setImage:image];
[cutVideoScroll addSubview:thumbnailsView];
});
但错误仍然存在。
感谢您的时间。
答案 0 :(得分:0)
你做对了,添加了子视图来查看触发器table.show-my-request-table tr td:first-child {
background-color: #ff0000;
}
。所以你应该只在主线程中添加视图。
也许您在任何覆盖的方法中都有专门用于iPhone / iPod的代码?
答案 1 :(得分:0)
这似乎是两件事的组合。
dispatch_async(dispatch_get_main_queue(), ^{
[thumbnailImageView setImage:image];
[cutVideoScroll addSubview:thumbnailsView];
});
并且在所有情况下,无论验证thumbnailImageView
image
if (! image)