gpt4 book ai didi

ios7 应用程序因 UItableview 中的内存压力而终止

转载 作者:行者123 更新时间:2023-11-29 02:54:00 26 4
gpt4 key购买 nike

我有 uitableview 和客户 UitableViewcell 我的单元格保存在 Uiimageview 中我使用Url将图像加载到我的UIimageView,因此在表格 View 中滚动时我的应用程序崩溃我的代码来源:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
ActusCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
NSDictionary *tmpDict = [_MyArray objectAtIndex:indexPath.row];

dispatch_async ( dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0ul), ^{
act_Image=[NSString stringWithFormat:@"http://www.exemple.com/act/%@%@",[tmpDict objectForKey:@"id"],@".jpeg"];
NSURL * imageURL = [ NSURL URLWithString :act_Image ];
NSData * imageDataUrl = [ NSData dataWithContentsOfURL : imageURL ];


dispatch_async ( dispatch_get_main_queue (), ^ {
[cell.myimage setImage:[UIImage imageWithData:imageDataUrl]];

});
});
return cell;
}

注意:URl 中的图像大小为 1.2MB

最佳答案

我认为您应该异步加载图像并将其保存在缓存中。因为有很多第三方源可用。我发现这是其中最好的-

1. https://github.com/nicklockwood/AsyncImageView2. https://github.com/rs/SDWebImage

关于ios7 应用程序因 UItableview 中的内存压力而终止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24138348/

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