gpt4 book ai didi

ios - 如何在TableView单元格中显示URL图像而不会卡住?

转载 作者:行者123 更新时间:2023-12-01 18:44:19 24 4
gpt4 key购买 nike

我已经在URLImage单元格中显示了tableview的集合。在滚动单元格时卡住了。我曾经使用过SDWebImageManagerAFNetWorking这样的第三方。牢房卡住的机会永远不会少。

[imageVw setImageWithURL:[NSURL URLWithString:self.imgaeRecord.PreviewURl]placeholderImage:[UIImage imageNamed:@"default-thumbnail.jpg"]];


NSURL *url =[NSURL URLWithString:[self.MoviesListImage objectAtIndex:indexPath.row]];

SDWebImageManager *manager = [SDWebImageManager sharedManager];
[manager downloadImageWithURL:url
options:0
progress:^(NSInteger receivedSize, NSInteger expectedSize) {
// progression tracking code
}
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
if (image) {
cell.recipeImageView.image = image;
}
}];

最佳答案

在您的cellForRowAtIndexPath中

NSURL *url =[NSURL URLWithString:[self.MoviesListImage objectAtIndex:indexPath.row]];

SDWebImageManager *manager = [SDWebImageManager sharedManager];
[manager downloadImageWithURL:url
options:0
progress:^(NSInteger receivedSize, NSInteger expectedSize) {
// progression tracking code
}
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
if (image) {
dispatch_async(dispatch_get_main_queue(), ^{
TableViewCellClass *updateCell = (id)[tableView cellForRowAtIndexPath:indexPath];
if (updateCell)
updateCell.yourImageView.image = image;
});
}
}
}];
[task resume];

关于ios - 如何在TableView单元格中显示URL图像而不会卡住?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37815285/

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