gpt4 book ai didi

ios - 我们使用此 Asyncimageview 类从 Web 服务获取图像并显示在 UItableview 中,但无法正常工作?

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

//UITableView   

NSString *data_image;

data_image = [[message_array objectAtIndex:indexPath.row] valueForKey:@"img_thumb"];

NSLog(@"data_image---%@",data_image);


if (![data_image isEqualToString:@""])
{
img_bubble = [[UIImageView alloc]initWithImage:cloudImage];
[img_bubble setFrame:CGRectMake(225, 0,85 , 80)];

img_buble_sender = [[UIImageView alloc]initWithImage:cloudImage1];

[img_buble_sender setFrame:CGRectMake(10,0,90,80)];

urlImage = [NSURL URLWithString:[[message_array objectAtIndex:indexPath.row] valueForKey:@"image"]];



asyncImage = [[AsyncImageView alloc]initWithFrame:CGRectMake(238, 10, 55, 55)];
[asyncImage loadImageFromURL:urlImage];

//images1=[[UIImageView alloc]initWithFrame:CGRectMake(238, 10,55 , 55)];
//[images1 setImageWithURL:urlImage];

}

最佳答案

在您的 cellForRowAtIndexPath 中试试这个:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
//create new cell
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

//common settings
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
cell.imageView.contentMode = UIViewContentModeScaleAspectFill;
cell.imageView.frame = CGRectMake(238, 10, 55, 55);
cell.imageView.clipsToBounds = YES;
}
else {
//cancel loading previous image for cell
[[AsyncImageLoader sharedLoader] cancelLoadingImagesForTarget:cell.imageView];
}

//set placeholder image or cell won't update when image is loaded
cell.imageView.image = [UIImage imageNamed:@"Placeholder.png"];

//load the image
cell.imageView.imageURL = [NSURL URLWithString:[[message_array objectAtIndex:indexPath.row];

return cell;
}

关于ios - 我们使用此 Asyncimageview 类从 Web 服务获取图像并显示在 UItableview 中,但无法正常工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19948979/

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