I am trying to import an image in just cell number 1 and 2 ! , but I the result is my image will show in last cell ! I do not know why !! this is the picture that shows my situation :

// Configure the cell.
NSUInteger row = [indexPath row];
cell.textLabel.text = [titles objectAtIndex:row];
cell.detailTextLabel.text = [subtitle objectAtIndex:row];
switch (indexPath.row) {
case 0:
cell.imageView.image = [UIImage imageNamed:@"new.png"];
break;
case 1:
cell.imageView.image = [UIImage imageNamed:@"new.png"];
break;
}
return cell;
}
Either in your
tableView:cellForRowAtIndexPath:set theimageView‘s image to nil before conditionally checking to set the new image or implementprepareForReuseon your cell subclass and set all of the cell’s views values to nil.This will ensure that reused cells are ‘clean’ before they’re brought on screen.
Alternatively you could edit your
switchto look like: