gpt4 book ai didi

ios - 仅在iPod中崩溃

转载 作者:行者123 更新时间:2023-12-03 17:14:32 25 4
gpt4 key购买 nike

CRASH是:

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.



显然,问题在于每次更改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。 ( 对此不确定,因为在我进行测试的所有设备中,这种情况永远不会发生,外面的人会通知我并向我发送错误日志)

My question is:


  • 此代码的哪一部分可能正在修改autoLayout,也许是[cutVideoScroll addSubview:thumbnailsView];
  • 为什么只在iPod上出现?

  • 更新:

    我正在测试。
    dispatch_async(dispatch_get_main_queue(), ^{
    [thumbnailImageView setImage:image];
    [cutVideoScroll addSubview:thumbnailsView];
    });

    但是错误仍然存​​在。

    谢谢你的时间。

    最佳答案

    正确无误,添加了 subview 以查看触发器layoutSubviews。因此,您应该仅在主线程中添加addViews。

    也许您有任何重写的方法专门针对iPhone / iPod编写了一些代码?

    关于ios - 仅在iPod中崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38897254/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com