I have created imageview to display image on cellForRowAtIndexPath method. and I add imageview in Cell as subview. But when I reload my tableview at that time the image in cell does not reload. following is my code.
- (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;
}
So, I want to remove my imageview to reload image properly.
How can I do that?
Try to add subviews to cell as :
You can remove that subviews using code :