我與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上的示例代碼..
謝謝!