嗨,我的问题是当我滚动UITableView
单元格图像时,实际上这些图像在网络服务器上发生变化,我使用 asyncdownloading 下载它。我已经添加了UIImageView
一个UITableViewCell
。图像成功显示,UITableViewCell
但是当我滚动 tableview 图像更改时,这是代码
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DefaultCell"];
searchobjectval =[self.arrSearchResult objectAtIndex:indexPath.row];
if(cell == nil)
{
cell =[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"DefaultCell"];
}
UILabel *areaLbl = (UILabel *)[cell viewWithTag:1];
UILabel *postTitle = (UILabel *)[cell viewWithTag:2];
UILabel *roomCost = (UILabel *)[cell viewWithTag:3];
UILabel *description = (UILabel *)[cell viewWithTag:4];
areaLbl.text =searchobjectval.location;
postTitle.text = searchobjectval.title;
roomCost.text = searchobjectval.roomCost;
description.text =searchobjectval.description;
[tableView setSeparatorColor:[UIColor blueColor]];
UIView *myView = [[UIView alloc] init];
if (indexPath.row % 2)
{
UIColor* clr = [UIColor colorWithRed:0.4f green:0.6f blue:0.8f alpha:1];
myView.backgroundColor = clr;
}
else
{
myView.backgroundColor = [UIColor whiteColor];
}
cell.backgroundView = myView;
NSLog(@" search object image %@",searchobjectval.imgLink);
// Pass along the URL to the image (or change it if you are loading there locally)
[AsyncImagesDownloading processImageDataWithURLString:[NSString stringWithFormat: @"http://192.95.48.72/bedspace/new_arrivals_img/%@",searchobjectval.idVal ] andBlock:^(NSData *imageData)
{
if (self.view.window)
{
UIImage *image = [UIImage imageWithData:imageData];
UIImageView *imgVw = (UIImageView *)[cell viewWithTag:10];
imgVw.image = image;
}
}];
return cell;
}