I have the following problem:
I have a UITableView with some Text and some Images as content. The TextLabel of the cell displays the text and I add a UIView with some UIImageViews as its subview to the cells contentview.
Everything works fine until I delete some cells. What happens is, I delete a cell (lets say the first) from the table, reload its data and e.g. then second cell moves one further up BUT! the UIView to the right contains the content from the first (deleted) cell.
I dont know why this happens - though I assume somethings wrong in me cellForRowAtIndexPath callback method.
I'll paste some code to make it clearer.
What I can do, is unload the controller and load it again - then the images contain the correct content again....
Heres my code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifierUNCHECK = @"MyIdentifierUNCHECK";
MyStuff *m = [allObjects objectAtIndex:indexPath.row];
UITableViewCell *cell = [tableViewdequeueReusableCellWithIdentifier:MyIdentifierUNCHECK];
UIView *v;
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifierUNCHECK] autorelease];
v = [[[UIView alloc] initWithFrame:CGRectMake(5.0, 5.0, 70.0, 70.0)] autorelease];
v.contentMode = UIViewContentModeScaleAspectFill;
[v addSubview:[[UIImageView alloc] init]];//some image view
[cell.contentView addSubview:v];
}
cell.textLabel.text = m.name;
cell.textLabel.numberOfLines = 0;
cell.textLabel.font = [UIFont fontWithName:@"Helvetica-BoldOblique" size:14.0];
cell.imageView.image = [UIImage imageNamed:@"checkbox.png"];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;