cellForRowAtIndexPath メソッドで画像を表示する imageview を作成しました。サブビューとして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;
}
そのため、イメージビューを削除してイメージを適切にリロードしたいと考えています。
どうやってやるの?