我与SDWebImage和UITableView的工作SDWebImage和UITableViewCell的
- (UITableViewCell *)tableView:(UITableView *)the_tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
NSString *MyIdentifier = [NSString stringWithFormat:@"MyIdentifier"];
NSDictionary *info = [tableData objectAtIndex:indexPath.row];
UITableViewCell *cell = [the_tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:MyIdentifier] autorelease];
if(!addImage) [addImage release];
addImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"placeholder.png"]];
[addImage setFrame:CGRectMake(7, 10, 50, 50)];
[cell setIndentationLevel:6];
[cell.contentView addSubview:addImage];
}
if(info != NULL) {
cell.textLabel.text = [info objectForKey:@"title"];
cell.detailTextLabel.text = [NSString stringWithFormat:@"Version: %@",[info objectForKey:@"version"]];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
NSString *imageURL = [NSString stringWithFormat:@"%@",[info objectForKey:@"imageURL"]];
[addImage setImageWithURL:[NSURL URLWithString:imageURL] placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
}
return cell;
}
它第6个结果的伟大工程(能适合于眼前的金额来看)
但正如我向下滚动列表中,它似乎只是重复使用前6个单元格中的图像,而在某些单元格上,图像会根据它们在屏幕上的位置而变化。另外,如果我调用reloadData,则来自先前UITableCells的图像将保留在屏幕上!
我在这里做错了什么?我遵循github上的示例代码..
谢谢!