Items mixed up after scrolling in UITableView

Posted by jean on Stack Overflow See other posts from Stack Overflow or by jean
Published on 2010-04-13T13:12:34Z Indexed on 2010/04/13 13:32 UTC
Read the original article Hit count: 343

Filed under:
|

When I scroll in my UITableView, the cells become mixed up. What am I doing wrong?

This is my method:

- (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] autorelease];
    }
    [cell insertSubview:[itemArray objectAtIndex:indexPath.row] atIndex:indexPath.row]; 
    return cell;
}

Update

It now works by using cell.contentView, but now when I select an item, the selected one is overlayed with the content of a different cell...

© Stack Overflow or respective owner

Related posts about iphone

Related posts about cocoa-touch