【发布时间】:2012-12-13 08:48:19
【问题描述】:
我创建了 imageview 以在 cellForRowAtIndexPath 方法上显示图像。我在 Cell 中添加 imageview 作为子视图。但是当我当时重新加载我的表格视图时,单元格中的图像不会重新加载。以下是我的代码。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[arrcathatname objectAtIndex:indexPath.row]]];
[imgView setFrame:CGRectMake(20, 7, 35, 35)];
[cell addSubview:imgView];
cell.textLabel.text = [arrCatName objectAtIndex:indexPath.row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
// Configure the cell...
return cell;
}
所以,我想删除我的 imageview 以正确重新加载图像。
我该怎么做?
【问题讨论】:
-
将子视图添加到 cell 或 cell.contentView??
-
尝试使用 [cell.contentView addSubview:imgView];
-
您是从服务器 url 获取图像吗?
标签: iphone objective-c uitableview